ThinkGeo.com    |     Documentation    |     Premium Support

OutOfMemory exception when zooming a map

We are using ThinkGeo Desktop WPF v12.2. Our 32-bit application is experiencing out of memory crashes when zooming (or resizing) a map. I created a topic on the exact same kind of out of memory exception in Mar of 2019 - OutOfMemory exception drawing a line in TrackInteractiveOverlay. The solution for the 2019 issue was to add this line of code, which solved our issue then:

wpfMap1.GCCollectionMode = GCCollectionMode.Forced;

I have noticed that the GCCollectionMode property is no longer available in v12.2. We are still seeing memory spikes when zooming a map (or resizing) that often results in an out of memory exception. Like before, this does not appear to be a memory leak - just a memory spike. Also, the memory spike is directly related to the monitor size and resolution and the size of the map window. For example, a large monitor with a high resolution and a full-screen map window produces a very high memory spike. Whereas, a smaller monitor with a lower resolution and/or a smaller map window produces a lower memory spike.

I have attached a sample application that demonstrates this issue. ThinkGeoPerformance-Tabs.zip (89.7 KB) Select the x86 platform when building the application. Use the following steps to reproduce this issue with the sample application:

  1. Use a large monitor with a high resolution (e.g., 48" 4K)
  2. Run the application
  3. Select the Add Tab button at the top of the application
  4. Full-screen the application
  5. Zoom the map in/out
  6. Use TaskManager to see the high memory spikes

Hi Rick,

This issue has been addressed in the latest beta release, version 14.3.0-beta042 or newer. As you’ve observed, it is a memory spike rather than a leak, it can occur in a 32-bit application running on a 4K monitor with multiple overlays.

We’ve implemented two key fixes:

  1. Memory is now released immediately after it is no longer needed.
  2. The UI has been enhanced to remain responsive under load. For example, if you pan the map while it is still rendering, the application will immediately cancel the previous operation and promptly release the memory.

These updates have been tested on 4K monitors with multiple overlays, and we have noted significant improvements in memory management. Currently, these improvements are available in the beta branch only and have not been included in the stable version (v14.2.1). We are planning to roll out a stable release in the next one to two weeks. I recommend testing the latest beta version in your application and transitioning to the release branch once it’s available.

Please note that version 14 utilizes asynchronous APIs, which will require updates to your code (e.g., replacing map.Refresh() with async map.RefreshAsync() ). While this may require some effort, particularly for larger projects, adopting asynchronous operations is a beneficial move in the long term. For guidance and sample code, you can refer to the ThinkGeo HowDoI samples https://gitlab.com/thinkgeo/public/thinkgeo-desktop-maps/-/tree/master/samples/wpf, which are now fully asynchronous.

Let us know if you have any questions.

Thanks,
Ben

Thank you for the reply!

Sure, just let us know if you have any questions.