Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Memory Leak? Collapse All
Subject Author Date
Eddie Judson Jul 24, 2005 - 7:37 PM

Hi,


   I changed the CMainApp::InitInstance() in the prof-uis controls sample application to the following:


if( m_pszProfileName != NULL )


free( (void*)m_pszProfileName );


m_pszProfileName =


_tcsdup( _T("ProfUIS_Controls") );


ASSERT( m_pszProfileName != NULL );


VERIFY(


g_CmdManager->ProfileSetup(


m_pszProfileName


)


);


CMainDlg* pdlg=NULL;


#ifdef _DEBUG


CMemoryState oldMemState, newMemState, diffMemState;


oldMemState.Checkpoint();


#endif


pdlg=new CMainDlg();


m_pMainWnd = pdlg;


int nResponse = pdlg->DoModal();


if (nResponse == IDOK)


{


// TODO: Place code here to handle when the dialog is


// dismissed with OK


}


else if (nResponse == IDCANCEL)


{


// TODO: Place code here to handle when the dialog is


// dismissed with Cancel


}


delete pdlg;


pdlg=NULL;



#ifdef _DEBUG


newMemState.Checkpoint();


if( diffMemState.Difference( oldMemState, newMemState ) )


{


TRACE( "Memory leaked!\n" );


diffMemState.DumpStatistics();


diffMemState.DumpAllObjectsSince();


}


#endif


// Since the dialog has been closed, return FALSE so that we exit the


// application, rather than start the application’s message pump.


return FALSE;


 


and ran it in debug mode, could you tell me how I can clean up properly as I am getting:


Memory leaked!


0 bytes in 0 Free Blocks.


12 bytes in 1 Normal Blocks.


36 bytes in 1 CRT Blocks.


0 bytes in 0 Ignore Blocks.


0 bytes in 0 Client Blocks.


Largest number used: 42589 bytes.


Total allocations: 137760 bytes


 


Regards,


 Eddie

Technical Support Jul 25, 2005 - 6:38 AM

There are no memory leaks in the ProfUIS_Controls sample application. The un-allocated block in the memory dump listed in your message will be de-allocated later during the application shutdown. This block is used by the internal API of the CExtHookSink class which is used by the CExtMenuControlBar class.

Eric Houvenaghel Aug 31, 2006 - 12:50 PM

I too am having memory leaks.
Many of them.
Thye look like the following:

Data: <{ > 7B C6 12 00
C:\Program Files\FOSS Software Inc\Prof-UIS\Src\ExtHook.cpp(579) : {41022} normal block at 0x01EDAC58, 29 bytes long.
Data: < 3 > CC D4 82 33 01 C0 AC ED 01 01 00 00 00 01 00 00
afxtempl.h(330) : {41021} normal block at 0x01EDAC10, 4 bytes long.

I thought I would run it by you before I start debuging this.

Technical Support Sep 1, 2006 - 5:32 AM

This typically means nothing is deallocated at all and, if you set a break point in the destructor of the main frame/dialog window, it will never be invoked in the debug mode. Please try debugging the deinitialization sequence and find out when and why the application terminates. This can be either an unhandled exception or an invocation of the ExitProcess() API.

Eric Houvenaghel Sep 6, 2006 - 11:42 AM

All destructors are invoked.
First of all, these memory leaks are comming from the CExtTabPageContainerWnd which derives from CExtHookSink.
Here is the situation.
I have a dialog containing a tab control.
This tab control is derived from CExtTabPageContainerWnd.
Using the PageInsert method, I insert my tab dialogs.
For debuging purpouses I’ve remove all tabs except for one.
So I now have a dialog with a tab control contianing one tab.
Inside this tab there is a dialog containing 3 edit contorls.
These edit controls are derived from CExtEdit.
All dialog were created in the resource manager.
The tab control is subclassed using DDX_Control(pDX, TABID, m_tabCtrl);
The edit boxes are subclassed using the MFC SubclassWindow function.
Now if I open this dialog and close it, and close my application, I get three memory leaks in my dump.
It seems to be one memory leak for each edit control (destructor is called in the edit control).

umping objects ->
afxtempl.h(330) : {19997} normal block at 0x01F00050, 4 bytes long.
Data: <_ > 5F 93 EF 01
C:\Program Files\FOSS Software Inc\Prof-UIS\Src\ExtHook.cpp(579) : {19996} normal block at 0x01EFFFE8, 29 bytes long.
Data: < B3 P > CC C4 42 33 01 50 00 F0 01 01 00 00 00 01 00 00
afxtempl.h(330) : {19993} normal block at 0x01EFFEF0, 4 bytes long.
Data: <_ > 5F 93 EF 01
C:\Program Files\FOSS Software Inc\Prof-UIS\Src\ExtHook.cpp(579) : {19992} normal block at 0x01EFFE88, 29 bytes long.
Data: < B3 > CC C4 42 33 01 F0 FE EF 01 01 00 00 00 01 00 00
afxtempl.h(330) : {19989} normal block at 0x01EFFD90, 4 bytes long.
Data: <_ > 5F 93 EF 01
C:\Program Files\FOSS Software Inc\Prof-UIS\Src\ExtHook.cpp(579) : {19988} normal block at 0x01EFFD28, 29 bytes long.

On line 139 in CExtHook there is the following code:

        if( bDelete )
            delete this;

If I put a break point on the line "delete this", I miss 3 hit.
Any help would be appreciated.

Technical Support Sep 7, 2006 - 12:42 PM

We have similar tab pages in the ProfUIS_Controls sample and we do not see any leak there. So, we can guess this depends on some conditions specific to your project only. Could you create a lightweight version of your project which generates leaks and send it to us?

Eric Houvenaghel Sep 8, 2006 - 10:12 AM

I’ve set a sample project to support@prof-uis.com.