Print Page | Close Window

Memory Leaks?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=5072
Printed Date: 21 November 2024 at 6:51am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Memory Leaks?
Posted By: martypku
Subject: Memory Leaks?
Date Posted: 17 September 2006 at 10:02pm

Version:8.7

VC6.0, SP6
 
I add the following code to CMainFrame::OnCreate to dynamically add a menu at run-time:
 
CXTPPopupBar *pBar = (CXTPPopupBar*) CXTPPopupBar::CreatePopupBar(GetCommandBars());
 CXTPControlPopup * pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);
 pControlPopup->SetCommandBar(pBar);
 pControlPopup->SetCaption("Test");
 pControlPopup->SetEnabled(TRUE);
 CXTPControl * pControl = GetCommandBars()->GetMenuBar()->GetControls()->Add(pControlPopup, -1, "", -1, FALSE);

 
VC reported memory leaks:
a CXTPControls object at $0003EDA0, 64 bytes long
a CXTPPopupBar object at $03037260, 408 bytes long
 
What's wrong?



Replies:
Posted By: Oleg
Date Posted: 18 September 2006 at 3:53am
Hi,
 
After this code add
pBar ->InternalRelease();


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: martypku
Date Posted: 18 September 2006 at 4:49am
Thanks! It works!
How can I know I must release an object by myself?


Posted By: Oleg
Date Posted: 18 September 2006 at 5:09am
It's one of exceptional situation in toolkit. because same popup bar can be assigned for different popup controls:
 
CXTPPopupBar *pBar = (CXTPPopupBar*) CXTPPopupBar::CreatePopupBar(GetCommandBars());

 pControlPopup1->SetCommandBar(pBar);
 pControlPopup2->SetCommandBar(pBar);
 
pBar ->InternalRelease();


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: martypku
Date Posted: 18 September 2006 at 6:02am

Did you mean:"Once I create a CXTPPopupBar and assign it to a popup control, I must release it"?



Posted By: Oleg
Date Posted: 18 September 2006 at 9:05am
yes.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: martypku
Date Posted: 18 September 2006 at 9:26am
Thanks!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net