Opened 11 years ago

Last modified 11 years ago

#11007 new defect

Memory leak when creating screenshots using wxMemoryDC.Blit()

Reported by: pulse00 Owned by:
Priority: normal Milestone:
Component: base Version:
Keywords: Cc:
Blocked By: Blocking:
Patch: no


wxMemoryDC or wxBitmap - don't know which one - does not free the memory after leaving the scope:

someFunction() {

wxScreenDC dcScreen;
wxCoord screenWidth, screenHeight;
dcScreen.GetSize(&screenWidth, &screenHeight);
wxBitmap screenshot(screenWidth, screenHeight,-1);
wxMemoryDC memDC;
memDC.Blit( 0, 0, screenWidth, screenHeight, &dcScreen, 0, 0);


i've attached a testcase to illustrate the problem. it creates 100 screenshots in an interval of 100 ms. observe the memory usage of the application.

On my machine (OSX), the app starts with about 20 MB memory, after the 100 screenshots it uses about 350 mb.

Attachments (1)

main.cpp download (1.5 KB) - added by pulse00 11 years ago.
leak testcase

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by pulse00

leak testcase

comment:1 Changed 11 years ago by Auria

I can reproduce this too on my computer (OS X too). I ran the test sample in Instruments and it showed me a few memory leaks (nowhere near 300 MB though). I can post the trace if you want but it should be relatively easy to reproduce (took me under 5 minutes)

Note: See TracTickets for help on using tickets.