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.