You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

Is there a known memory leak in the geoproc...   Ronnen Levinson Nov 13, 2005
Re: Is there a known memory leak in the geo...   Dan Patterson Nov 13, 2005
Re: Is there a known memory leak in the geo...   Dave Bollinger Nov 14, 2005
Re: Is there a known memory leak in the geo...   Ronnen Levinson Nov 17, 2005
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Is there a known memory leak in the geoprocessor of ArcGIS 9.1? 
Author Ronnen Levinson 
Date Nov 13, 2005 
Message Hi.

I have found that calling certain functions that check for, delete, or create rasters in a personal geodatabase--e.g.,

GP.exists()
GP.delete()
GP.Clip_management()
GP.ExtractByPolygon_sa()

-- leads PythonWin (2.4 and 2.1; I've tried both) to consume ever-increasing amounts of memory. For example, if I have a geodatabase workspace that contains many rasters, 100 calls to GP.exists() increases PythonWin memory use by about 25 MB.

I observe the same sort of trouble when executing the code below, which populates a geodatabase with many small rasters, each extracted by polygon from a large raster. After several hundred iterations, PythonWin's memory consumption increases to 1 GB from about 100 MB, and the geoprocessor aborts with a complaint about memory availability.

I have tried removing (via del) the result of those calls that return values, such as GP.exists; this has no useful effect.

Is there a known memory leak in the geoprocessor, or perhaps a known tendency toward gratuitious caching? Is there any way to avoid the problems I describe, and/or encourage the geoprocessor (rather than Python) to perform garbage collection?

Thanks,

Ronnen. 
 
clippedRasterExists = GP.exists(clippedRaster)
for i in range(nrows):
    outRaster = labelList[i]
    outRasterExists = outRaster in outWorkspaceRasters
    if overWrite and outRasterExists:
        print "Deleting " + outRaster
        GP.delete(outRaster)
    if (not outRasterExists) or overWrite:        
        inPolygon = polygonList[i]
        inBoundingBox = boundingBoxList[i]
        if clippedRasterExists:
            print "Deleting " + clippedRaster
            GP.delete(clippedRaster)
        print str(i) + ": Creating clipped raster " + clippedRaster + " ("+inBoundingBox+")"
        GP.Clip_management(inWorkspace + "/" + inRaster, inBoundingBox, clippedRaster)
        clippedRasterExists = True
        print str(i) + ": Creating new " + outRaster
        GP.ExtractByPolygon_sa(clippedRaster, inPolygon, outRaster, "INSIDE")
    else:
        print str(i) + ": Skipping " + outRaster + " (already exists)"
 
  Ronnen Levinson
ArcView 9.1
Python 2.4
WinXP Pro SP2
3.2GHz P4, 3GB RAM 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Is there a known memory leak in the geoprocessor of ArcGIS 9.1? 
Author Dan Patterson 
Date Nov 13, 2005 
Message have you been following the other threads on leaks? eg
http://forums.esri.com/Thread.asp?c=93&f=1729&t=173610&mc=6 
  Geomatics, Carleton University, Ottawa, Canada 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Is there a known memory leak in the geoprocessor of ArcGIS 9.1? 
Author Dave Bollinger 
Date Nov 14, 2005 
Message I don't know if the geoprocessor itself leaks, maybe, maybe not, but Python itself has some memory issues.

I'm also running 2.4 and it still seems to be the case that once Python allocates a block of physical memory it never releases it. Deleting variables and getting their reference count to zero only makes that block internally available for Python to reuse again -- it doesn't free the memory to the system. The physical memory is only truly freed when the Python process terminates. So basically python.exe will have a memory footprint of your peak memory usage.
 
  Dave Bollinger
Programmer/Analyst
San Joaquin County, CA 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Is there a known memory leak in the geoprocessor of ArcGIS 9.1? 
Author Ronnen Levinson 
Date Nov 17, 2005 
Message Hi Dan and Dave.

Thanks for your advice. I've employed the subprocess workaround discussed in the related thread

http://forums.esri.com/Thread.asp?c=93&f=1729&t=173610&mc=6

It's ugly but it works.

Ronnen. 
  Ronnen Levinson
ArcView 9.1
Python 2.4
WinXP Pro SP2
3.2GHz P4, 3GB RAM