ArcMap/ArcObjects 10.8 with VB2019 compiled against .NET Framework 4.6
I have the need to process a very large amount of polylines against a raster using the ExtarctByMask gp. Saving the result sub-raster to memory is up to 5x faster than saving to disk so I opt to use the in_memory workspace.
However RAM usage keeps building because the GP functions do not clear up these in_memory objects. My pseudo code looks something like this:
for every polylineFeat
'extract a sub-raster as intersection of input raster and polyline feature
Dim extBymsk As ExtractByMask = New ExtractByMask
extBymsk.in_raster = inRastName
extBymsk.in_mask_data = polylineFeat
extBymsk.out_raster = "in_memory\" & subRasterName
'get properties of the sub-raster
Dim rastProps As GetRasterProperties = New GetRasterProperties
'done with the sub-raster so delete it
Dim delData As Delete = New Delete
delData.in_data = "in_memory\" & subRasterNamer
every 100 iterations delete in_memory workspace
Dim delWksp As Delete = New Delete
delWksp.in_data = "in_memory"
'garbage collect and wait
GC.Collect()
GC.WaitForPendingFinalizers()
end every 100 iterations
'test to see if the sub-raster is truly gone from memory
Dim rastPropsB As GetRasterProperties = New GetRasterProperties
next polylineFeat
The Delete_management for rasters in_memory just does not work. How do I know this? I put a test GP function GetRasterProperties AFTER the Delete operation and i can still get a result. It should throw an exception if the raster didn't exist.
So I have about 7000 polylines to process and this routine throws an exception at about 2800 polylines. The reason is that RAM has been saturated for this thread.
Has anyone else seen this? What have you done as a workaround? I contacted tech support and they say they will file a bug. But I need to process data today and the last bug I filed took 18 months to fix. I cant believe we are at 10.8 and the in_memory workspace still has defects.
Any help appreciated.
~Abel