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

Mirko Dziadzka mirko.dziadzka at gmail.com
Tue Dec 17 11:14:12 EST 2013


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)


# show memory leak
import gc
from reportlab.lib import xmllib

assert xmllib.sgmlop # check that we are using FastXMLParser

while True:
parser = xmllib.XMLParser(verbose=0)
parser.close()
gc.collect()


How to reproduce
==============

Just start this program and watch the memory going up … see the 6th column in the ps output below

$ while sleep 10 ; do ps auxww | grep python | grep -v grep ; done
mirko 1023 100,0 0,3 2467680 25608 s000 R+ 5:10pm 1:00.44 python t.py
mirko 1023 100,0 0,3 2469728 27424 s000 R+ 5:10pm 1:10.47 python t.py
mirko 1023 99,3 0,3 2471520 29048 s000 R+ 5:10pm 1:20.50 python t.py
mirko 1023 100,0 0,4 2472288 30616 s000 R+ 5:10pm 1:30.54 python t.py


I tested this with reportlab-2.5 and reportlab-2.7 on CentOS-6-64bit and MacOS 10.8 with Python 2.7 and Python 2.6

Analysis
=======

It seems that there is a cyclic reference between FastXMLParser and sgmlop and parser.close() is not cleaning up.

Using the SlowXMLParser instead of XMLParser is working fine.




More information about the reportlab-users mailing list