I am running a maya python script that runs through the scene and reduces the polygon count of a mesh object if it is above a certain range.
This runs fine on a small scene, but when I run it on thousands of mesh objects, the memory use of my machine counts up and up until maya freezes at around 80% of the physical memory use.
My question is, can I add some kind of memory flush, other than what I already have, into the python loop that will 'reset' the memory use? Or is this impossible, as the thread is still running?
I am running this:
selectedObjects = ls (sl=True, fl=True)
for obj in selectedObjects:
reduceMesh(obj) # my function
cmds.flushUndo()
cmds.clearCache( all=True )
cmds.DeleteHistory()
Adding the flush undo seems to help a little, but I still see the memory rise...