4

I'm running a loop that create feature classes at a geodatabase. After creating 221 datasets I get the error message "pyscripter out of memory". Is there a way to clear the physical memory of computer in order to resume with the script ? I've alredy tried :

  gc.enable
  clear = lambda: os.system('cls')
  clear()
  gc.collect()

Windos Task Manager enter image description here enter image description here Out of Memory in pyscripter

  • You really need to post some code for us to see what might be happening. – Nathan W Jan 15 '14 at 9:29
  • Have you tried running the script via IDLE? – Aaron Jan 15 '14 at 19:38
2

I would start first looking for a place to figure out at which time the memory gets full. The memory consumption can be monitored with an extra module psutil, which is a great cross-platform library for obtaining information on running processes and system utilization (i.e., CPU, memory, disks, network). I guess you could also use any other logging techniques in your code that Python has to control the memory use.

Another general thing you might want to try is to use a module subprocess; there is a great post on how to use this module here. You basically would try to spawn new processes, then connect to their pipes, and obtain their return codes.

  • When it's using 1,588,692K in Memory(Private Working Set) and 25 in CPU – mahmoud hageer Jan 15 '14 at 8:50
2

If you're creating an artifact in memory, like a FeatureLayer, with each iteration, you could be piling up the memory you use. I would look for places where arcpy.Delete_management() could be used, rather than the garbage collector. arcpy could maintain connections to what are in reality unused variables in such a way as to fool the gc module.

2

As Nathan suggested you really need to post the code for a proper answer. We are all just guessing at this point...

But one think that may be causing you a problem is a memory leak with a cursor? In ArcGIS 10.1 you can use the search cursor with a WITH statement which guarantees its release. Have a look at the code sample here to see how to use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.