[reportlab-users] memory leak in reportlab xmllib.FastXMLParser
Mirko Dziadzka
mirko.dziadzka at gmail.com
Tue Dec 17 14:35:01 EST 2013
This solves the immediate problem. However, the problem reappear on higher levels.
All code using ParaParser must call close() to free the memory.
But even reportlab internal code does not do this in every case.
The program below reconstruct the memory leak on a higher level.
import gc
from reportlab.platypus.paragraph import Paragraph
from reportlab.lib.styles import ParagraphStyle
normalStyle = ParagraphStyle('normal')
# construct input which can not be decoded as utf-8
# this will throw an exception in the parser
brokenInput = unichr(228).encode("iso-8859-1")
while True:
try:
p = Paragraph(brokenInput, normalStyle)
except Exception, e:
# will complain about invalid encoding ....
# NOTE that I have NO WAY of cleaning up the memory here ...
pass
gc.collect()
On 17.12.2013, at 18:53, Robin Becker <robin at reportlab.com> wrote:
> I find this fixes the issue
>
>> diff -r d7705185366c src/reportlab/lib/xmllib.py
>> --- a/src/reportlab/lib/xmllib.py Tue Dec 17 13:58:46 2013 +0000
>> +++ b/src/reportlab/lib/xmllib.py Tue Dec 17 17:52:50 2013 +0000
>> @@ -524,6 +524,8 @@
>> try:
>> self.parser.close()
>> finally:
>> + self.feed = None
>> + del self.parser
>> self.parser = None
>>
>> # Interface -- translate references
>
> I will check this in the trunk code tomorrow
>
>
> On 17/12/2013 17:35, Mirko Dziadzka wrote:
>>
> ...........
>
> --
> 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