<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Memory Leak When Binding Map Property in Esri MapView (WPF, Prism Application) in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/memory-leak-when-binding-map-property-in-esri/m-p/1631282#M13601</link>
    <description>&lt;P&gt;Hi Support,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are experiencing a memory leak issue in our WPF application when using the esri:MapView control from the ArcGIS Runtime SDK.&lt;/P&gt;&lt;P&gt;We are using &lt;STRONG&gt;Prism with DryIoC&lt;/STRONG&gt; to dynamically load and unload views at runtime.&lt;/P&gt;&lt;P&gt;Our application uses a custom RegionAdapter and RegionActiveAwareBehavior to manage the lifecycle of views within regions.&lt;/P&gt;&lt;P&gt;Here is the problem:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;When we instantiate MapView &lt;STRONG&gt;without binding the Map property&lt;/STRONG&gt;, and remove the view via the region manager, the view and MapView are both disposed correctly. No memory leaks are observed.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;esri:MapView x:Name="EsriMapView" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;However, if we bind the Map property as shown below:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;esri:MapView x:Name="EsriMapView" Map="{Binding Map}" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then a memory leak occurs. The view is removed from the region, but the MapView and its associated resources are &lt;STRONG&gt;not released&lt;/STRONG&gt;, even after explicitly clearing layers and unsetting the map reference.&lt;/P&gt;&lt;P&gt;In the view's unload logic, we attempt the following cleanup:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (EsriMapView.Map is Map map)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.OperationalLayers.Clear();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.Basemap?.BaseLayers.Clear();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;EsriMapView.Map = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Despite this, memory is not released properly, and repeated navigation results in increased memory usage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your reference I have attached the sample application. I’m to using ViewA of ModuleA which is inside the DevExpress LayoutControl control.&lt;BR /&gt;&lt;BR /&gt;Please let me know if you have any suggestions on how to avoid this memory leak.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Ben&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jul 2025 19:41:20 GMT</pubDate>
    <dc:creator>BenjaminMazenko</dc:creator>
    <dc:date>2025-07-08T19:41:20Z</dc:date>
    <item>
      <title>Memory Leak When Binding Map Property in Esri MapView (WPF, Prism Application)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/memory-leak-when-binding-map-property-in-esri/m-p/1631282#M13601</link>
      <description>&lt;P&gt;Hi Support,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are experiencing a memory leak issue in our WPF application when using the esri:MapView control from the ArcGIS Runtime SDK.&lt;/P&gt;&lt;P&gt;We are using &lt;STRONG&gt;Prism with DryIoC&lt;/STRONG&gt; to dynamically load and unload views at runtime.&lt;/P&gt;&lt;P&gt;Our application uses a custom RegionAdapter and RegionActiveAwareBehavior to manage the lifecycle of views within regions.&lt;/P&gt;&lt;P&gt;Here is the problem:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;When we instantiate MapView &lt;STRONG&gt;without binding the Map property&lt;/STRONG&gt;, and remove the view via the region manager, the view and MapView are both disposed correctly. No memory leaks are observed.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;esri:MapView x:Name="EsriMapView" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;However, if we bind the Map property as shown below:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;esri:MapView x:Name="EsriMapView" Map="{Binding Map}" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then a memory leak occurs. The view is removed from the region, but the MapView and its associated resources are &lt;STRONG&gt;not released&lt;/STRONG&gt;, even after explicitly clearing layers and unsetting the map reference.&lt;/P&gt;&lt;P&gt;In the view's unload logic, we attempt the following cleanup:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (EsriMapView.Map is Map map)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.OperationalLayers.Clear();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.Basemap?.BaseLayers.Clear();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;EsriMapView.Map = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Despite this, memory is not released properly, and repeated navigation results in increased memory usage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your reference I have attached the sample application. I’m to using ViewA of ModuleA which is inside the DevExpress LayoutControl control.&lt;BR /&gt;&lt;BR /&gt;Please let me know if you have any suggestions on how to avoid this memory leak.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Ben&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2025 19:41:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/memory-leak-when-binding-map-property-in-esri/m-p/1631282#M13601</guid>
      <dc:creator>BenjaminMazenko</dc:creator>
      <dc:date>2025-07-08T19:41:20Z</dc:date>
    </item>
  </channel>
</rss>

