This project is read-only.

Memory usage increases without control

Dec 7, 2011 at 12:11 PM
Hi everybody,

I'm developing a airplane tracking software that shows the movement of targets on a vectorial map. It works quite good, without any exception/error.

Testing the program memory usage, I realize that it increases without limit. I have isolated the problem, I know that is related with the DrawPoint() method and the memory management of the drawing layers.

There is a variable that stores the location of the airplane, I'm simulating the movement of the objects by checking target position and drawing a point there every tick of a timer, cleaning old drawings previously in order to simulate the screen refreshment. It works fine, shows all that I want.
Here's a simplified example in C# based on my source code:

public partial class Visor : Form, MapWinGIS.ICallback, IDisposable

int tracking_screen; //Screen drawing layer handle
MapWinGis.Point plane; //Data Structure that stores the plane location

public Visor()

private void Visor_Load(object sender, EventArgs e)
plane=new MapWinGis.Point();



private void timer1.tick()
tracking_screen=axMap1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList); // <<---- May be the problem it´s here



The memory increase only happens when the timer is enabled so I think is due to I use the new drawing assignment for the point (NewDrawing) every tick, may be it reserves memory in each call and the ClearDrawing method don't free the room used by the drawing layer.

You would think the problem can be solved by deleting the code line that contains the call to NewDrawing method, I have tried it but after Clearing Drawing it doesn't shows the new point drawn, you can't draw a point and show it on the screen without calling first the NewDrawing method.

What can I do? Am I doing something wrong?

Thanks in advance.

Apr 25, 2012 at 9:15 AM

Hi David,

Have you got the solution for the above problem? If yes, could you just let me know the solution to it.




Sep 1, 2014 at 5:30 PM
Edited Sep 1, 2014 at 5:31 PM

I Don't know if anyone is still interested but doing rather the same code with 4.8.8, I found also that Cleardrawing disables future drawings to the same layer and that it's necessary to recall NewDrawing. With following lines, in a loop, I didn't notice memory increase and drawing handler keeps the same value
With WinMap1
.DrawPointEx(gpsLayer, gps.x, gps.y, 12, 255)
end With
By the way, I noticed that it's necessary to set .DisableWaitCursor = True to avoid cursor update during .Redraw() but setting it to false and true again doesn't work, cursor keeps updating after "false"....

As a conclusion, it seems that ClearDrawing should be RemoveDrawingLayer and that there is no function EraseDrawing.

Dec 2, 2014 at 4:12 PM
Checked this issue for pre-release version of v.4.9.3. Wasn't able to reproduce anything in both cases. a) ClearDrawing indeed works as RemoveDrawingLayer. It should be called for each NewDrawing call. Otherwise there will be a leak. And indeed there is no way to clear the drawing layer only to remove it, which is a pity, will add it to my TODO list. b) DisableWaitCursor after such "true -> false -> true" scenario hides cursor as it should.