Hi, anyone come across memory leaks in ArcMap running selectionset search. Feature cursors are released using System.Runtime.InteropServices.Marshal.FinalReleaseComObject
pSpatialFilter = New ESRI.ArcGIS.Geodatabase.SpatialFilterClass() With pSpatialFilter .Geometry = pPoint .GeometryField = m_pFeatureClass.ShapeFieldName .SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects End With
If looping thousands of features ... memory in ArcMap.exe process in Task Manager keeps growing until ArcMap crashes. This only happends with SQL Server Express ... running the same code with Personal gdb (MS Access) has no leaks. Not sure how to release the selectionset explicitly.
joseph833, Howdy interestingly I'm working today on debugging what looks like an ESRI memory leak doing almost EXACTLY what you are doing. I hate to post without a solution, but I've not got one yet. However, since misery loves company, I thought I'd share what we know so far. We have a very similiar spatial selectionset query just like you do, which is inside a tight loop and is memory leaking BADLY!
For our case a couple of interesting things to note ( which might help you in your investigations) : - We can't find anything in our code we might be doing wrong. We're cleaning up the selection set after the query, and even forcing GC.collect (which we SHOULDN"T have to do...) - it makes no difference. - We're running arc10 sp4 client, but ArcSDE Oracle 9.3 on the server, in direct-connect mode - we're going to upgrade our server and see if that helps it go away. (so this is a pretty unique combination there) - Our target featureclass for the spatial query is a polygon featureclass with some VERY complicated polygons... something like 36 polys with over 4millions vertices between them all... the complexity of this featureclass seems to have a big bearing on the size of our leak. Other more simple featureclasses running thru the same code don't appear to leak, or at least they are not as noticable, and probalby GC has time to 'catch up'. - Running the SAME query through the ArcMap UI, using ArcMap UI - select by location processing over and over manually seems to exhibit the same leak for us! So, we hope further evidence that its not necessarily our ArcObjects code. - Running the same query through a personal or file GDB (not SDE) is NOT leaking- it seems fine. - We're betting its an incompatibilty/bug on the SDE-side of things at this point.
If I find a solution to our problem, I'll repost here...hopefully you'll do the same as well, Best regards toward finding it, Tim
Howdy all, One further bit of information to this, we did upgrade our server-side database to sde 10 and an arc10 version geodb and that didn't solve it. I'm planning to log a trouble ticket with esri at this point. thanks TY