- all python objects get destroyed automatically
- files stay open
- memory leak per document_new_from_file(): 40 kB (for a 300 kB pdf file)
- gc.collect() does nothing
If you call g_object_unref(hash(doc)) after each call to
document_new_from_file() the problems go away:
- all python objects get destroyed automatically
- files are closed
- memory leak per document_new_from_file(): 70 bytes (for a 300 kB pdf file)
- gc.collect() does nothing
- doc is completely usable after g_object_unref(...)
BTW: hash(obj) returns the pointer to the gobject of a PyGobject.
Here is a simple test case:
=================================
import os
import poppler
from ctypes import *
glib = CDLL("libgobject-2.0.so")
uri = "file://" + os.path.abspath("test.pdf")
for i in xrange(1000000):
print i
doc = poppler.document_new_from_file(uri, None)
glib.g_object_unref(hash(doc))
====================================
On Fri, Apr 10, 2009 at 11:23 PM, Gian Mario Tagliaretti
<email address hidden> wrote:
>
> I've looking into this one for a long time with no real solution but I
> feel the GC could be the one to blame, did you investigate further?
I did investigate further and did some testing:
Current release:
- all python objects get destroyed automatically new_from_ file(): 40 kB (for a 300 kB pdf file)
- files stay open
- memory leak per document_
- gc.collect() does nothing
If you call g_object_ unref(hash( doc)) after each call to new_from_ file() the problems go away:
document_
- all python objects get destroyed automatically new_from_ file(): 70 bytes (for a 300 kB pdf file)
- files are closed
- memory leak per document_
- gc.collect() does nothing
- doc is completely usable after g_object_unref(...)
BTW: hash(obj) returns the pointer to the gobject of a PyGobject.
Here is a simple test case:
======= ======= ======= ======= =====
import os
import poppler
from ctypes import *
glib = CDLL("libgobjec t-2.0.so" )
uri = "file://" + os.path. abspath( "test.pdf" ) document_ new_from_ file(uri, None) g_object_ unref(hash( doc)) ======= ======= ======= ======= =
for i in xrange(1000000):
print i
doc = poppler.
glib.
=======
On Fri, Apr 10, 2009 at 11:23 PM, Gian Mario Tagliaretti
<email address hidden> wrote:
>
> I've looking into this one for a long time with no real solution but I
> feel the GC could be the one to blame, did you investigate further?