ThinkGeo.com    |     Documentation    |     Premium Support

Memory Usage Question

Hello,

In my current app, I have several LayerOverlays and a FeatureLayerWpfDrawingOverlay, which is used to plot several objects around gps locations. The standard LayerOverlays are used to display basic shapefiles and a ThinkGeoMBTilesLayer.

Currently I do not have any cache defined on the MBTilesLayer.

in my current setup, I have a “heading north” option, that as the gps positions move, pans and rotates the map using ZoomToAsync. This all works fine.

My actual question is… when I start my application and items are being drawn, the app uses lets say 180 mb of ram (according to task manager). as the position moves around and the map is rotated, the memory usage will slowly creep up which has in many cases caused out of memory exceptions. This application may have to run for several days at a time before resetting.

This morning, out of curiosity, I switched a toggle so that the map zoomed back to the stationary object and no longer rotated, and over the course of a few hours the memory finally started dropping to the original levels.

What I’m wondering is if there is a cache or some other feature that I can/should be clearing regularly, either on the overlays or on the layers themselves, to help manage memory more efficiently.

I’ve tried looking at the BitmapTileCache and ExpirationTime on the mb tiles layer, but the tile cache is null since I haven’t defined anything.

Any insight you can provide is appreciated.

Hi Aaron,

Here are a few things you may want to check:

  1. Is your application running as x86 or x64?
    If it’s x86, the OutOfMemoryException may not be caused by physical memory exhaustion, but by hitting the ~2GB virtual address space limit of a 32-bit process.

  2. This may not be a memory leak, but a memory peak during rendering.
    When the map is rotated, more tiles are loaded to cover the visible extent, which increases memory usage. If your application is already close to the memory limit, enabling rotation could push it over the edge.

    A few things you could try to reduce the number of tiles being loaded:

    • Set
      overlay.TileBuffer = 0;
      This limits tile loading to only those strictly within the current extent.

    • Disable in-memory tile caching:
      overlay.TileViewInMemoryCache = null;

    • If possible, consider combining some LayerOverlays to reduce the total number of overlays being rendered.

  3. Could you let us know:

  • Your screen resolution
  • Windows scale factor (Settings → System → Display → Scale)
  • How many TileOverlay instances you currently have

This information will help us narrow down the cause.

Thanks,
Ben

Hello Ben,

Thanks for your quick response.
Currently the app is running on x64. These are low end machines though, and only have a total of 4gb of ram. Not the best, but it overall suits our needs.

The screen resolution is also low at 1360x768 with the scaling set to 100%.
I actually don’t currently have any TileOverlays (which I suppose could be part of the issue).

I have two LayerOverlays and one FeatureLayerWpfDrawingOverlay.

In the mean time I’ll move the ThinkGeoMBTilesLayer into a ThinkGeoMBTilesOverlay to see if it helps, as well as setting the TileBuffer = 0.

Hi Aaron,

4GB is indeed on the lower end for this kind of application, which makes it more susceptible to OOM under heavy tile loading. Give the suggestions a try and let us know how it goes!

Thanks,
Ben