AnsweredAssumed Answered

Count features intersecting buffered geometry - memory leak

Question asked by bgs on Dec 1, 2014
Latest reply on Dec 8, 2014 by bgs

Hi All,

 

I'm calling the function below several thousand times, but it just seems to increase memory usage until it falls over. I've tried Marshal.ReleaseComObject and ComReleaser without any luck. It seems to be related to the buffered geometry as if I give the non buffered geometry (SiteGeometry) to pSpatialFilter it seems fine.

 

Any ideas how i release the memory used by this function?

 

thanks,

Andy

 

 

Public Function doSearch(ByVal SiteGeometry As IGeometry, ByVal SearchLayer As IFeatureClass, ByVal Buffer As Integer, ByVal shapeField As String) As Integer

        Dim topoOP As ITopologicalOperator2

        Dim pSpatialFilter As ISpatialFilter = New SpatialFilter

 

        topoOP = SiteGeometry

        topoOP.Simplify()

        Dim pGeometryBuff As IGeometry = topoOP.Buffer(Buffer)

      

        With pSpatialFilter

            .Geometry = pGeometryBuff

            .GeometryField = shapeField

            .SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects

        End With

        Dim theRowcount As Integer = SearchLayer.FeatureCount(pSpatialFilter)

 

        topoOP = Nothing

        pSpatialFilter = Nothing

        pGeometryBuff = Nothing

        pBC = Nothing

 

        Return theRowcount

    End Function

Outcomes