Print Page | Close Window

Memory Leak on CommandBars destruction

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=11015
Printed Date: 01 March 2025 at 3:00am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Memory Leak on CommandBars destruction
Posted By: Paolo
Subject: Memory Leak on CommandBars destruction
Date Posted: 13 June 2008 at 2:50am
ToolkitPro MFC version 12.0.0:
I built a simple MFC application, just run it and immediatly close. In my VS2008 IDE the output shows some memory leaks that are related to command bars structure. Here's the relevant output:

Codejock ToolkitPro Terminating!
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {400} normal block at 0x020D1938, 26 bytes long.
 Data: <d  x            > 64 99 7F 78 09 00 00 00 09 00 00 00 01 00 00 00
f:\microsoft visual studio 9.0\vc\atlmfc\include\afxtempl.h(401) : {399} normal block at 0x020D18F8, 4 bytes long.
 Data: <H   > 48 17 0D 02
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {398} normal block at 0x020D1FB8, 27 bytes long.
 Data: <d  x            > 64 99 7F 78 0A 00 00 00 0A 00 00 00 01 00 00 00
c:\programmi\codejock software\mfc\xtreme toolkitpro v12.0.0\source\commandbars\xtpcontrolbutton.cpp(35) : {397} client block at 0x020D1748, subtype c0, 372 bytes long.
a CXTPControlButton object at $020D1748, 372 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {396} normal block at 0x020D1F58, 30 bytes long.
 Data: <d  x            > 64 99 7F 78 0D 00 00 00 0D 00 00 00 01 00 00 00
c:\programmi\codejock software\mfc\xtreme toolkitpro v12.0.0\source\commandbars\xtpcommandbar.cpp(198) : {395} normal block at 0x020D1EE8, 48 bytes long.
 Data: <p     `x        > 70 1B 0D 02 C4 A1 60 78 00 00 00 00 00 00 00 00
c:\programmi\codejock software\mfc\xtreme toolkitpro v12.0.0\source\commandbars\xtpcontrols.cpp(51) : {394} client block at 0x020D1E68, subtype c0, 68 bytes long.
a CXTPControls object at $020D1E68, 68 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {393} normal block at 0x020D1E10, 27 bytes long.
 Data: <d  x            > 64 99 7F 78 0A 00 00 00 0A 00 00 00 01 00 00 00
c:\programmi\codejock software\mfc\xtreme toolkitpro v12.0.0\source\commandbars\xtppopupbar.cpp(1723) : {392} client block at 0x020D1B70, subtype c0, 608 bytes long.
a CXTPPopupToolBar object at $020D1B70, 608 bytes long
Object dump complete.


The line I'm actually focused on is follows:

c:\programmi\codejock software\mfc\xtreme toolkitpro v12.0.0\source\commandbars\xtpcommandbar.cpp(198)


I included <XTToolkitPro.h> in stdafx.h, derived MainFrm class from CXTPMDIFrameWnd and in MainFrm.cpp file I modified
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

function by adding the code block I copied here:

if ( !InitCommandBars() ) return -1;

CXTPCommandBars  *commandBars_p  = GetCommandBars();  // Get Command Bars
CXTPCommandBar   *commandBar_p   = commandBars_p->Add("My Command Bar", xtpBarTop);  // Add Command Bar
CXTPControl      *control_p      = commandBar_p->GetControls()->Add(xtpControlSplitButtonPopup, 20000);  // Add new Split Button Popup to the command bar
CXTPControlPopup *controlPopup_p = static_cast<CXTPControlPopup *>(control_p);  // cast to CXTPControlPopup
CXTPPopupToolBar *popupToolBar_p = CXTPPopupToolBar::CreatePopupToolBar(commandBars_p);  // Create Popup ToolBar
popupToolBar_p->SetTearOffPopup("Popup ToolBar", 20002);  // Set PopupToolBar as Tear Of
controlPopup_p->SetCommandBar(popupToolBar_p);  // Link CXTPControlPopup to PopupToolBar

CXTPControl      *control2_p     = popupToolBar_p->GetControls()->Add(xtpControlButton, 20001);
control2_p->SetCaption("Control 2");  // Add Button to the PopupToolBar


I checked CXTPCommandBar destructor (xtpcommandbar.cpp lines 201 and following) and Command Bar titled "My Command Bar" is correctly deleted. But I can not find deletion of the CXTPPopupToolBar I created with
CXTPPopupToolBar::CreatePopupToolBar method.

I'm not sure if it's me not deleting correctly something or if something is missing in Codejock code.
Can somebody help me?



Replies:
Posted By: Oleg
Date Posted: 13 June 2008 at 6:35am
Hi,
 
yes, after you link popupToolBar_p to controlPopup_p you have decreate reference counts:
 
controlPopup_p->SetCommandBar(popupToolBar_p);
popupToolBar_p->InternalRelease();


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



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