![]() |
GUI Resource Problem |
Post Reply
|
| Author | |
Tsenoh
Groupie
Joined: 08 November 2006 Status: Offline Points: 69 |
Post Options
Thanks(0)
Quote Reply
Topic: GUI Resource ProblemPosted: 15 February 2007 at 10:08am |
|
Hi!
In my application I am using Dialogs with ribbons. Dialogs are often opened and closed. Whenever I close a dialog I don't destroy it. I just destroy all elements in it. I use RemoveAllTabs to destroy Ribbon elements. This way I don't have to initialise dialog every time it is opened. I just recreate the child controls.
Problem occures when I open and close same dialog multiple times (10-15 times). Suddenly GUI goes crazy. No button can be drawn, all windows use default font, etc. It seems that GUI handles are not released when a control is destroyed.
Has anyone had similar problem?
Any ideas how I can solve this problem?
Thanks!
Bojan Hrnkas
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 15 February 2007 at 11:11am |
|
Hi
May be you call InitCommandBars each time you show dialog or something.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Tsenoh
Groupie
Joined: 08 November 2006 Status: Offline Points: 69 |
Post Options
Thanks(0)
Quote Reply
Posted: 19 February 2007 at 11:12am |
|
I did indeed. However that was not the problem. I am using SetCustomIcon() for my buttons. I figured out that there is a memory leak in that function, so I have around 700 leaks per dialog start. If those leaks are all icon handles, or any other gui handles, I understand the problem.
Is there something I have to do to destroy resources created by SetCustomIcon()?
|
|
![]() |
|
kstowell
Admin Group
Joined: 25 January 2003 Location: MIchigan, USA Status: Offline Points: 496 |
Post Options
Thanks(0)
Quote Reply
Posted: 19 February 2007 at 12:37pm |
|
HI Tsenoh,
You can try using CXTPImageManagerIconHandle instead of HICON. This will automatically clean up your icon resources when the object is destroyed.
Instead of:
HICON hIcon = Use: CXTPImageManagerIconHandle hIcon = Hope this helps. Regards,
Kirk Stowell
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 February 2007 at 2:03am |
|
Hello,
SetCustomIcon each time reserves new Id for Icon. I very recommend yo use SetIcons method instead.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Tsenoh
Groupie
Joined: 08 November 2006 Status: Offline Points: 69 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 February 2007 at 9:57am |
|
If I understood corectly. When using SetIcons, icons are mapped through controll message id. We use our own message system, and the ID's are only unique within a dialog. Not within the application. That is why I use SetCustomIcon.
|
|
![]() |
|
Tsenoh
Groupie
Joined: 08 November 2006 Status: Offline Points: 69 |
Post Options
Thanks(0)
Quote Reply
Posted: 28 September 2007 at 11:07am |
|
Hi!
I've now checked my application using following tool: http://www.download.com/DPusLight/3000-2218_4-10424495.html?tag=pdp_prod
It shows that resources created by CreateCompatibleBitmap are not freed untill I destroy the dialog. I am never calling CreateCompatibleBitmap myself for theese icons (in the tool there is an image of the resources in question), so it has to be somewhere in the XTP code.
However, those resources are not created each time I show the dialog, so it is not really a leak. It seems to me that is some kind of cache for the bitmaps that are to be drawn on the ribbon.
Is there a possibility to disable it? Since my application has hundreds of dialogs that are dynamicaly created, the GDI Resource count pretty soon reaches the magic number 10.000.
Any ideas?
Thanks!
|
|
![]() |
|
Tsenoh
Groupie
Joined: 08 November 2006 Status: Offline Points: 69 |
Post Options
Thanks(0)
Quote Reply
Posted: 28 September 2007 at 1:48pm |
|
Hi, again! Please consider following code:
pImage is never deleted. Is that a leak, or am I missing something and that objects are destroyed elsewhere? Thanks!
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 29 September 2007 at 1:54am |
|
Hi,
Images are stored in CXTPOffice2007Images class and will be destroyed after skin changed or in destructor of this class.
Better attach code you use in your dialog, I will check where you forget to free resources.
Our library doesn't have memory leaks.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Tsenoh
Groupie
Joined: 08 November 2006 Status: Offline Points: 69 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 October 2007 at 5:47am |
|
I see. I know the problem now. We are not destroying the Dialog Object, so the CXTPOffice2007Images isn't destroyed as well. Is there a possibility to empty that map and destroy it's elements other than destroying the Object itself?
Thanks!
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 October 2007 at 5:59am |
|
Hi,
Call
((CXTPOffice2007Theme*)pCommandBars->GetPaintManager())->GetImages()->RemoveAll();
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Tsenoh
Groupie
Joined: 08 November 2006 Status: Offline Points: 69 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 October 2007 at 10:04am |
|
Ok, that solved a part of the problem.
Thanks a lot!
Other leaks are probably in our code.
Some other thing, I see that Fonts are stored with each CXTPRibbonBar instance. Probably again in the Theme. They don't take up much space, but it would be nice if I could destroy them too.
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 October 2007 at 1:40pm |
|
HI,
If you use CommandBars/PaintManager only with this dialog, you can free all PaintManager:
CXTPPaintManager::Done()
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
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 |