[Checkins] SVN: z3c.soap/trunk/ add test for memory leak in zsi soapwriter & update buidout
Jean-Francois Roche
jfroche at jfroche.be
Tue Sep 22 13:14:00 EDT 2009
Log message for revision 104431:
add test for memory leak in zsi soapwriter & update buidout
Changed:
U z3c.soap/trunk/buildout.cfg
U z3c.soap/trunk/docs/HISTORY.txt
U z3c.soap/trunk/setup.py
U z3c.soap/trunk/z3c/soap/README.txt
U z3c.soap/trunk/z3c/soap/ftests.py
A z3c.soap/trunk/z3c/soap/mem.txt
U z3c.soap/trunk/z3c/soap/soap.py
-=-
Modified: z3c.soap/trunk/buildout.cfg
===================================================================
--- z3c.soap/trunk/buildout.cfg 2009-09-22 16:27:06 UTC (rev 104430)
+++ z3c.soap/trunk/buildout.cfg 2009-09-22 17:14:00 UTC (rev 104431)
@@ -7,12 +7,16 @@
develop =
.
-
+versions = versions
eggs =
ZSI
unzip = true
+[versions]
+Products.GenericSetup <= 1.4.4
+five.localsitemanager = 1.1
+
[zope2]
recipe = plone.recipe.zope2install
url = http://www.zope.org/Products/Zope/2.10.6/Zope-2.10.6-final.tgz
Modified: z3c.soap/trunk/docs/HISTORY.txt
===================================================================
--- z3c.soap/trunk/docs/HISTORY.txt 2009-09-22 16:27:06 UTC (rev 104430)
+++ z3c.soap/trunk/docs/HISTORY.txt 2009-09-22 17:14:00 UTC (rev 104431)
@@ -1,6 +1,12 @@
Changelog
=========
+0.5 - (2009-09-22)
+------------------
+
+* fix & test memory leak in zsi soapwriter
+* buildout update
+
0.4 - (2009-05-04)
------------------
Modified: z3c.soap/trunk/setup.py
===================================================================
--- z3c.soap/trunk/setup.py 2009-09-22 16:27:06 UTC (rev 104430)
+++ z3c.soap/trunk/setup.py 2009-09-22 17:14:00 UTC (rev 104431)
@@ -8,6 +8,8 @@
description="Soap using ZSI in Zope 2",
long_description=open(os.path.join("z3c", "soap",
"README.txt")).read() + "\n" +
+ open(os.path.join("z3c", "soap",
+ "mem.txt")).read() + "\n" +
open(os.path.join("docs", "HISTORY.txt")).read(),
classifiers=[
"Environment :: Web Environment",
Modified: z3c.soap/trunk/z3c/soap/README.txt
===================================================================
--- z3c.soap/trunk/z3c/soap/README.txt 2009-09-22 16:27:06 UTC (rev 104430)
+++ z3c.soap/trunk/z3c/soap/README.txt 2009-09-22 17:14:00 UTC (rev 104431)
@@ -685,3 +685,4 @@
Content-Type: text/xml
<BLANKLINE>
...jfroche at affinitic.be is OK...
+
Modified: z3c.soap/trunk/z3c/soap/ftests.py
===================================================================
--- z3c.soap/trunk/z3c/soap/ftests.py 2009-09-22 16:27:06 UTC (rev 104430)
+++ z3c.soap/trunk/z3c/soap/ftests.py 2009-09-22 17:14:00 UTC (rev 104431)
@@ -100,6 +100,13 @@
doctest.REPORT_ONLY_FIRST_FAILURE|
doctest.NORMALIZE_WHITESPACE,
setUp=setUp, tearDown=tearDown, globs=globs)
+ ftest = FunctionalDocFileSuite(
+ 'mem.txt',
+ optionflags=doctest.ELLIPSIS|
+ doctest.REPORT_NDIFF|
+ doctest.REPORT_ONLY_FIRST_FAILURE|
+ doctest.NORMALIZE_WHITESPACE,
+ setUp=setUp, tearDown=tearDown, globs=globs)
ftest.layer = z3c_soap_functional_layer
return ftest
Added: z3c.soap/trunk/z3c/soap/mem.txt
===================================================================
--- z3c.soap/trunk/z3c/soap/mem.txt (rev 0)
+++ z3c.soap/trunk/z3c/soap/mem.txt 2009-09-22 17:14:00 UTC (rev 104431)
@@ -0,0 +1,58 @@
+Mem tests
+=========
+
+ >>> import sys
+ >>> from xml.dom.minidom import Element, Node
+ >>> print sys.getrefcount(Element)
+ 5
+ >>> from z3c.soap.tests.mailvalidation import ns1
+ >>> from ZSI import SoapWriter
+ >>> from ZSI import TC
+ >>> element = ns1.ValidateEmailRequest_Dec().pyclass()
+ >>> element._Email = 'foo at bar.be'
+ >>> sw = SoapWriter(nsdict={}, header=True, outputclass=None,
+ ... encodingStyle=None)
+ >>> tc = TC.Any(aslist=1, pname='test')
+
+We serialize more than one copy of the previously created element
+
+ >>> res = sw.serialize([element, element, element, element, element], tc)
+ >>> print sys.getrefcount(Element)
+ 19
+ >>> print sw
+ <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><test xmlns:ns1="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2:Messages" SOAP-ENC:arrayType="xsd:anyType[5]" xsi:type="SOAP-ENC:Array"><ns1:element><ns1:Email xsi:type="xsd:string">foo at bar.be</ns1:Email></ns1:element><ns1:element><ns1:Email xsi:type="xsd:string">foo at bar.be</ns1:Email></ns1:element><ns1:element><ns1:Email xsi:type="xsd:string">foo at bar.be</ns1:Email></ns1:element><ns1:element><ns1:Email xsi:type="xsd:string">foo at bar.be</ns1:Email></ns1:element><ns1:element><ns1:Email xsi:type="xsd:string">foo at bar.be</ns1:Email></ns1:element></test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+ >>> print sys.getrefcount(Element)
+ 19
+ >>> del res
+ >>> del sw.body.node
+ >>> del sw.body
+ >>> del sw.dom.node
+ >>> del sw.dom
+ >>> del sw
+ >>> print sys.getrefcount(Element)
+ 19
+
+So when a soapwriter is deleted there are still 19 references to Element active (this can be a
+disaster with large xml).
+
+What if we unlink the nodes first::
+
+ >>> sw = SoapWriter(nsdict={}, header=True, outputclass=None,
+ ... encodingStyle=None)
+ >>> res = sw.serialize([element, element, element, element, element], tc)
+ >>> print sys.getrefcount(Element)
+ 33
+ >>> Node.unlink(sw.body.node)
+ >>> Node.unlink(sw.dom.node)
+ >>> print sys.getrefcount(Element)
+ 22
+ >>> del res
+ >>> del sw.body.node
+ >>> del sw.body
+ >>> del sw.dom.node
+ >>> del sw.dom
+ >>> del sw
+ >>> print sys.getrefcount(Element)
+ 20
+
+There are thus less references to Element when using unlink before deleting the soapwriter object.
Modified: z3c.soap/trunk/z3c/soap/soap.py
===================================================================
--- z3c.soap/trunk/z3c/soap/soap.py 2009-09-22 16:27:06 UTC (rev 104430)
+++ z3c.soap/trunk/z3c/soap/soap.py 2009-09-22 17:14:00 UTC (rev 104431)
@@ -20,6 +20,7 @@
import traceback
from zope.interface import implements
from z3c.soap.interfaces import ISOAPResponse
+from xml.dom.minidom import Node
class SOAPParser(object):
@@ -119,6 +120,12 @@
sw = SoapWriter(nsdict={}, header=True, outputclass=None,
encodingStyle=None)
body = str(sw.serialize(result, tc))
+ Node.unlink(sw.dom.node)
+ Node.unlink(sw.body.node)
+ del sw.dom.node
+ del sw.body.node
+ del sw.dom
+ del sw.body
except:
self.exception()
return
More information about the checkins
mailing list