1

I'm using dotSpatials Map object to do some operations on a shape file. My program eats up memory when I'm using the code below to add a layer (MapLineLayer) and when I'm done with the layer I want my memory back. I can't manage to dispose of my Map object and it's layers.

        Map map = new Map {Projection = ProjectionInfo.FromEpsgCode(epsgCode)};
        try
        {
            map.AddLayer(filePath);
        }

How can I properly dispose dotSpatials Map?

4

1 回答 1

0

Try ClearLayers(). If Map object is not disable and still causes memory leaks it may be a bug... Having said that, keep in mind that garbage collector will not release you memory immediately the Map control goes out of scope.

If you want you can execute GC.Collect immediately after you finish with the Map control (for testing purposes) but it is not necessary to put this code in your application as the Garbage Collector manages it properly.

GC.Collect();
GC.WaitForPendingFinalizers();
于 2015-07-15T22:21:09.290 回答