I am having a performance issue related to the scenario above involving trying to make a buffered selection based on an initial selection. The issue seems to explode into a memory leak that eventually renders the entire site non-responsive. The memory consumption jumps to surpluses of 1GB and eventually I am given an out of memory error.
This is how I obtain the original selection from a rectangle track shape:
Dim highlightLayer As InMemoryFeatureLayer = GeoMap.DynamicOverlay.Layers("HighlightLayer")
Dim parcelLayer As FeatureLayer = GeoMap.StaticOverlay.Layers("Parcels")
Dim fCollection As System.Collections.ObjectModel.Collection(Of Feature)
Dim bufferLayer As InMemoryFeatureLayer = GeoMap.DynamicOverlay.Layers("BufferLayer")
parcelLayer.Open()
highlightLayer.InternalFeatures.Clear()
bufferLayer.InternalFeatures.Clear()
Dim trackShape As PointShape = e.Position
fCollection = parcelLayer.QueryTools.GetFeaturesIntersecting(trackShape, New String() {})
For Each fFeature As Feature In fCollection
If Not highlightLayer.InternalFeatures.ContainsKey(fFeature.Id) Then highlightLayer.InternalFeatures.Add(fFeature.Id, fFeature)
Next
parcelLayer.Close()
GeoMap.EditLayer.InternalFeatures.Clear()
GeoMap.DynamicOverlay.Redraw()
ScriptManager.RegisterClientScriptBlock(panelInfo, GetType(UpdatePanel), "callBuffer", "tabManager('Buffer');", True)
Then the user is given options of the units of measure and the amount to buffer the selection. At this point we can assume it will always be feet and the input will be 100. At this point unioning the features takes some times but goes through, but I am frozen at the buffer request which is what creates the memory leak. It's worth mentioning that if the collection of features is small then eventually the buffer completes, but I should be able to do this with 1000's of features without fear of system crash:
Protected Sub cmdBufferOk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdBufferOk.Click
Dim highlightLayer As InMemoryFeatureLayer = DirectCast(GeoMap.DynamicOverlay.Layers("HighlightLayer"), InMemoryFeatureLayer)
Dim bufferLayer As InMemoryFeatureLayer = DirectCast(GeoMap.DynamicOverlay.Layers("BufferLayer"), InMemoryFeatureLayer)
Dim parcelLayer As FeatureLayer = GeoMap.StaticOverlay.Layers("Parcels")
highlightLayer.Open()
Dim fselectedFeatures As IEnumerable(Of Feature)
fselectedFeatures = highlightLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.NoColumns)
Dim baseShape As MultipolygonShape = AreaBaseShape.Union(fselectedFeatures)
Dim bufferedShape As MultipolygonShape = baseShape.Buffer(txtBuffer.Text, GeographyUnit.Meter, DistanceUnit.Feet)
Dim bufferFeature As New Feature(bufferedShape)
bufferLayer.Open()
'bufferLayer.InternalFeatures.Clear()
bufferLayer.InternalFeatures.Add("BufferFeature", bufferFeature)
bufferLayer.Close()
highlightLayer.InternalFeatures.Clear()
parcelLayer.Open()
Dim fCollection As System.Collections.ObjectModel.Collection(Of Feature)
fCollection = parcelLayer.QueryTools.GetFeaturesIntersecting(bufferFeature, New String(1) {"STREETNUMB", "STREETNAME"})
For Each fFeature As Feature In fCollection
If Not highlightLayer.InternalFeatures.ContainsKey(fFeature.Id) Then highlightLayer.InternalFeatures.Add(fFeature.Id, fFeature)
Next
parcelLayer.Close()
highlightLayer.Close()
GeoMap.EditLayer.InternalFeatures.Clear()
GeoMap.DynamicOverlay.Redraw()
ScriptManager.RegisterClientScriptBlock(panelInfo, GetType(UpdatePanel), "callInfo", "tabManager('Information');", True)
spnInfo.InnerHtml = GetIdentifyContent(fCollection, 50)
End Sub