2

I am running a Python script to make point feature layer from a series of netCDF files and then perform a spatial join with a number of polygons and save the results as a table. I am using arcpy.MakeNetCDFFeatureLayer_md and address its output to a variable in 'in_memory' workspace. My problem is that even though I am deleting the 'in_memory' after each loop using arcpy.Delete_management('in_memory'), it does not free up my RAM and after a couple of iterations I run into Memory Error. The function that is being called for each netCDF file looks like this:

def spatialJoin(nc):
    arcpy.env.overwriteOutput = True
    arcpy.env.workspace = 'in_memory'
    arcpy.MakeNetCDFFeatureLayer_md(nc, "SM", "lon", "lat", "SMPoints", "time;lat;lon", "", "", "", "BY_VALUE")

    <does the spatial join>

    print arcpy.Exists('SMPoints')
    arcpy.Delete_management('SMPoints')
    print arcpy.Exists('SMPoints')

And the console prints:

True
False 

for each iteration, which means Delete_management is working. But checking the python process in windows task manager shows that the data is piling up in RAM! I have tried deleting individual features inside 'in_memory' as well as deleting the whole 'in_memory' but nothing seems to work. Am I missing something here?

P.S. Spatial join does not affect the problem here, problem exists even when I completely comment out the spatial join section.

1

You shouldn't need to set your environment workspace to in_memory as you are doing in your script, so you can drop this line:

arcpy.env.workspace = 'in_memory'

Also, ensure that you are using double-quotes when referencing your in_memory workspace inside of the geoprocessing tool.

arcpy.Delete_management("in_memory")
  • 3
    "ensure that you are using double-quotes when referencing your in_memory workspace" - that's a new one for me, can you explain/reference the double-quotes requirement over single-quotes? – Midavalo Aug 19 '16 at 21:12
  • Thanks @Radar, but changing to double-quote didn't help! – Monobakht Aug 20 '16 at 11:55

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.