Addressing Memory leak in IFeatureClass.Search (only on SDE with direct connect) of ArcObjects?
This looks like a bug.
SG contains the ArcSDE geometry libraries and not the ArcObjects geometry libraries... it is used as a pre-filter before the test hits the ArcObjects geometry libraries.
Try this:
Omit this line:
pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
and since you are not saving a reference to the row, there is no need for you not to use recycling cursors, so switch the false flag to true.
pCursor = (ICursor)pFeatureClass.Search(pSpatialFilter, true);
You should see an improvement both in memory consumption and runtime speed. Nevertheless, if the bug is still hit, this will hopefully dramatically delay it :)
If anyone is still interested in this, it was fixed at Version 10.1.
ESRI Technical Support Number: NIM070156 and NIM062420
http://support.esri.com/en/bugs/nimbus/TklNMDcwMTU2 http://support.esri.com/en/bugs/nimbus/TklNMDYyNDIw