Yes this has been reported before and a known issue to Autodesk and
claimed-fixed in 2009 and to my testing thus far it has been.

On Sat, Apr 11, 2009 at 8:43 AM, Byron <[email protected]> wrote:
>
> ... and I truly hope that whatever I found out is just my mistake,
> already solved and not as terrible as it appears, so here it comes:
> Whenever you make a call to maya.cmds.<commandname>, an arglist and a
> your list of kwargs will be stored as tuples and held. These tuples
> will never be collected or deleted, and thus consume memory.
> This starts becoming an issue if you call a command a few 10 thousands
> of times.
>
> I could verify this issue on Maya8.5 64 linux and Maya2008 OSX.
>
> I assume that someone in the c-part of the cmds wrap does not
> decrement the refcount on the tuples created, thus python keeps
> thinking they are in use. The refcount of these tuples 3(-1) in Maya
> 8.5 and 4(-1) in Maya2008.
>
> Is this a known bug ? If not it would be great if anyone with a nice
> support contract could bring it up :).
>
> Cheers,
> Sebastian ( being so incredibly disappointed right now )
>
> The Code :
> Makes 10 runs and calls simple mel commands 1000 times, checking the
> garbage collectors object count after each run.
> The collection cannot get ahold of these objects being continuously
> added to the collector.
> As these commands are read-only, the undo-queue cannot be involved.
> If you rewrite the loop so that it uses the pymel API wrap for
> instance, the gc's object count will not raise.
> If you want to crank up the numbers, you will see that this really
> consumes memory once the object count hits a million and if you issue
> a little more complex commands.
>
> <pre>
> import sys
> import gc
> assert gc.isenabled()
> import maya.cmds as cmds
>
> for run in range( 10 ):
>        print "%i: Pre-cmds execution: %i" % ( run, len( gc.get_objects() ) )
>        for i in range( 1000 ):
>                cmds.listRelatives( "persp", shapes = 1, ni = 1 )
>                cmds.ls( sl=1 )
>        print "Post-cmds execution: %i" % len( gc.get_objects() )
>
> # the garbage collection cannot get ahold of these objects
> assert gc.collect() == 0
>
> # lets check the refcount on these tuples
> lobj = gc.get_objects()[-1]
> print "%s.refcount = %i" % ( lobj, sys.getrefcount( lobj ) )
>
> # just to be sure: yes, its our arguments we passed to the cmds
> for obj in gc.get_objects()[-50:]: print obj
> </pre>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to