AnsweredAssumed Answered

VB.Net code crashing after looping through ~8000 records using a spatial query

Question asked by USForestServiceAdmin on Feb 23, 2012
Latest reply on Feb 23, 2012 by Neil
Hello all,

I really hope there is someone out there who can help.  I was on the phone with ESRI support yesterday for 2.5 hours.  This code worked fine in ArcGIS 9.3.1.  Can anybody see anything I can change?

This code is returning the number of adjacent polygons to each polygon in a layer, then populating an attribute in the table with that number.  Later on in the code I label the layer in ArcMap with this number so the user can easily see how many polygons are neighboring each polygon in the layer.  This tool is used for vertical integration.  Is there anything in ArcGIS 10 that would cause this code to work differently than it did in 9.3.1? 

                Dim pSpRef As ISpatialReference = Nothing
                pSpRef = m_pfc.Fields.Field(nShpFieldNDX).GeometryDef.SpatialReference

                pFeat = pFeatCur.NextFeature

                While Not pFeat Is Nothing
                    nNumAdjacent = 0
                    nCurRecNo = nCurRecNo + 1

                    With pSpFltr
                        .Geometry = pFeat.Shape
                        .SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches
                        .OutputSpatialReference("Shape") = pSpRef   'm_pfc.Fields.Field(nShpFieldNDX).GeometryDef.SpatialReference
                        .SubFields = "Shape"
                        .GeometryField = "Shape"
                    End With

                    pSelSet = m_pfc.Select(pSpFltr, esriSelectionType.esriSelectionTypeSnapshot, esriSelectionOption.esriSelectionOptionNormal, Nothing)

                    pFeat.Value(lFld) = pSelSet.Count
                    pFeat.Store()

                    My.ArcMap.Application.StatusBar.Message(0) = nCurRecNo.ToString & "/" & n.ToString & " records complete."
                    Me.ProgressBar1.Value = nCurRecNo
                    comReleaser.ManageLifetime(pFeat)
                   
                    'Marshal.ReleaseComObject(pFeat)

                    pFeat = pFeatCur.NextFeature

                    Application.DoEvents()
                End While

Outcomes