Memory usage when using Maps

When you are finished with a map object you need to call Dispose. You can have the CLR do this for you automatically if you use your maps like so:

using (Map map = new Map(center, width, height, zoom)) {
  ...
   Image image = map.GetMap();
   ...
}

This will dispose 'map' at the end of the using block.

 This is because the unmanaged memory used by the Map object cannot be seen by the Garbage Collector, and therefore the Map object isn't collected as soon as it should. Disposing the map as above will free the unmanaged memory.

The Image returned from map.GetMap() is tied to the Map object. It will therefore be invalid after the Map is disposed. If you wish to continue using the Image outside of the block, you must Clone it to make a copy, eg:

Image image;
using (Map map = new Map(center, width, height, zoom)) {
   ...
   image = map.GetMap().Clone();
   ...
}

CryptoAPI service provider could not be acquired Streets and other features do not appear at certain zoom levels