amlanroy100

Memory problem while inserting raster in raster catalog

Discussion created by amlanroy100 on Feb 15, 2012
Latest reply on Feb 17, 2012 by amlanroy100
Hi,

I am facing memory problem while inserting images in raster catalog.
I have a schedule job which have to run 12 hrs on daily basis, but after 3.5 hours it is throwing out of memory exception

The system I am using is configured with  OS- Windows server 2008 R2 with physical memory 8GB, ArcGIS desktop 10.0, Visual Studio 2010 Ultimate

below is code to insert:-

                    rasterDataset = rasterWorkSpace.OpenRasterDataset(imageName);
                    featureBuffer = featureClass.CreateFeatureBuffer();
                    rasterValue = new RasterValueClass();
                    rasterValue.RasterDataset = rasterDataset;
                    featureBuffer.set_Value(rasterCatalog.RasterFieldIndex, rasterValue);
                    insertCursor.InsertFeature(featureBuffer);
                    counter++;
                    Console.WriteLine(string.Format("Processing...Count:{0},", counter));
                    if (counter % 100 == 0)
                    {
                        insertCursor.Flush();
                        Console.WriteLine("Flushing cursor");
                    }

I am Flushing cursor after processing every 100 records.


I have noticed Memory(Private Working State) usage in windows task manager, and it increases abnormally.
I have notices that every hour the memory increases almost 450 MB. When the memory reaches 1.6 GB, the application crashes.

I have released all com object in this way:-
                if (rasterWorkspaceFactory != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(rasterWorkspaceFactory);
                if (rasterWorkSpace != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(rasterWorkSpace);
                if (rasterDataset != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(rasterDataset);
                if (rasterValue != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(rasterValue);
                if (featureBuffer != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(featureBuffer);
                if (insertCursor != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(insertCursor);
                if (rasterCatalog != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(rasterCatalog);
                if (rasterWorkspaceEx != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(rasterWorkspaceEx);


Any help will be highly appreciated.

Regards
Amlan Roy

Outcomes