![]() |
CXTPImageManager Memory Leak? |
Post Reply ![]() |
Author | ||
Danlar ![]() Groupie ![]() ![]() Joined: 27 February 2008 Location: United States Status: Offline Points: 12 |
![]() ![]() ![]() ![]() ![]() Posted: 27 February 2008 at 12:26pm |
|
I'm executing code which removes icons from the image manager and adds new ones in their place every time a ribbon control gets updated. The memory used by the application climbs very quickly while this happens. Visual Studio doesn't report any memory leaks when the program exits, though, so whatever is allocating all of them is cleaning them up during the exit.
Consider this code which sometimes will execute very very frequently:
When this code is executing, the memory usage by my application climbs very quickly. If I remove the calls to RemoveIcon and SetIcon, the memory stops climbing. Any idea what's going on? Before anyone asks, I am certain that control->getID() is returning the same value every time this function is getting executed. This rules out the option of constantly removing zero icons and adding two more. Also I've tried throwing this->GetCommandBars()->GetImageManager()->GetImages()->GetCount() into the function in various places, and it does decrease in value and re-increase exactly as I'd expect. -Dan |
||
![]() |
||
Danlar ![]() Groupie ![]() ![]() Joined: 27 February 2008 Location: United States Status: Offline Points: 12 |
![]() ![]() ![]() ![]() ![]() |
|
Well, I fixed it. But, I'm not sure why or how. It's probably something very simple I've overlooked.
If I replace my SetIcon calls with SetIcons instead, everything gets better. I changed...
into...
and the memory usage has stopped climbing. I've either missed a fundamental feature of MAKEINTRESOURCE or LoadBitmapFromResource, or I really don't understand the difference between SetIcon and SetIcons. Thanks in advance for any insight. -Dan |
||
![]() |
||
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
|
Hi,
LoadBitmapFromResource created BITMAP that you had to destroy.
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
![]() |
||
Danlar ![]() Groupie ![]() ![]() Joined: 27 February 2008 Location: United States Status: Offline Points: 12 |
![]() ![]() ![]() ![]() ![]() |
|
So I added code to my function above to delete the HBITMAP for each of the icons before removing them...
DeleteObject returns TRUE each time, indicating it did successfully delete the HBITMAP. This doesn't fix the constantly growing amount of memory though. |
||
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |