[reportlab-users] memory leak in reportlab xmllib.FastXMLParser

Mirko Dziadzka mirko.dziadzka at gmail.com
Tue Dec 17 12:35:55 EST 2013

Using the Slow Parser by disabling the sgmlop solved my immediate problem. Our paragraphs are short ;-)

After a second look on FastXMLParser, there seems to be 2 references to the sgmlop parser.

self.parser = sgmlop.XMLParser()
self.feed = self.parser.feed

and close() is only setting self.parser to None, self.feed still has a reference to sgmlop.

changing FastXMLParser.close() by adding a

self.feed = None

removes the memory leak in the simple example.

OTOH ... I'm not sure if paraparser is calling close() on the xmllib in all cases.

On 17.12.2013, at 18:13, Robin Becker <robin at reportlab.com> wrote:

> I suspect we've had this problem for a long time in the sgmlop c extension module. Originally the paraparser.py module used to create just one parser for use by all the paragraph instances, but I think Andy recent changed that to create one for each instance in a vain attempt to stop threading issues.


> I'll take a look at the sgmlop.c code to see if I can spot this; that code is very old and not our originally. It certainly doesn't cooperate with GC at all.



> On 17/12/2013 16:14, Mirko Dziadzka wrote:

>> Hi


>> I’m not sure if this is the right list for a bug report, any pointers to another address are welcome.


>> Problem description

>> ===============


>> The following program creates a memory leak.


>> As a result, using reportlab.platypus.paraparser.ParaParser creates a memory leak too.

>> As a result, wordaxe has a memory leak (my original problem)


> ........


> --

> Robin Becker

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

More information about the reportlab-users mailing list