Forum: Poser Python Scripting


Subject: find memory leak?

colorcurvature opened this issue on Nov 02, 2011 · 3 posts


colorcurvature posted Wed, 02 November 2011 at 4:47 PM

Hi, I noticed memory goes down when I execute my script, and it doesnt return. The more often its executed, the more the memory goes down.

What I did was this:

def _dbg_dump_gc( ):
    #l = []
    #l.append(l)
    gc.set_debug(gc.DEBUG_SAVEALL)
    print gc.collect( )
    print gc.collect( )
    print 'leaks:'
    for i in gc.garbage:
        pprint.pprint (i)
    print 'end of leaks.'
    del gc.garbage[:]

 

but that isnt printing anything except the gc.collect return values, which are 0, unless I decomment that part with an intentional hanging self-referring list.

but that isnt evening printing the global variables. I wonder why. maybe some more flags have to be set?

 

thanks a lot!

col


nruddock posted Wed, 02 November 2011 at 5:03 PM

I suspect the problem you're running into is due to the fact that all objects you get from Poser are implemented in native code and that the memory is leaking because the underlying allocated memory can't be released by the Python garbage collector.

The only thing you can do is to try using del on large lists, tuples, and arrays allocated via numeric or numpy, to see if you can improve the situation.

It may also be the case that the use of native objects prevent the debugging tools from detecting where leaks are occuring.


colorcurvature posted Wed, 02 November 2011 at 5:11 PM

Its a bit strange yes. maybe it has to be accepted and put as a limitation into the readme files or manual.