Dealing with memory leaks in Python scripts in 10.0

Discussion created by treemanforest on Mar 7, 2014
Latest reply on Mar 11, 2014 by mdenil
I'm looking for strategies to deal with buggy memory leaks in v10.0

My script does some geoprocessing (mostly intersections and selections) on about 3000 polygons, using searchcursors as well. The script is pretty simple, but as it runs I watch the Memory Usage in task manager creep up to about 1.3 GB and then ArcGIS crashes with no warning.

So then I amended my script to keep track of how far the results got to on the last attempt, and to carry on from there. But this means manually restarting the procedure each time. I'd much rather devise some means to restart the script periodically, say every 500 polygons, but I can't figure out how to 'reset all' in Python.

What are the options for dealing with and working around ArcGIS's buggy memory leaks? What are the overall strategies? I currently run scripts from the Python window but it would be fairly easy to get them to work as standalone scripts. I haven't figured out how, in a standalone script, to periodically release all memory or resources, so if anyone has any tips on how to kill the ArcMap.exe process and start afresh that would be really helpful. That way, potentially I can scale my script to work on bigger datasets without having to crash and restart it several times.