|
-
January 30th, 2006, 06:08 AM
#1
Unknown memory leak.. Need help..
My program is working pretty well however there is a memory that occurs and i don't know how to trace it. I've tried to delete the cWinThread object, terminate the thread. but still the leak is there..
Here is some of the code:
 Originally Posted by Code
Under .h:
CWinThread* cThread1;
CWinThread* cThread2;
static UINT StartThread1 (LPVOID param);
static UINT StartThread2 (LPVOID param);
Under .cpp:
// Create thread begin execution
void MainChildDlg2::OnStartButton()
{
cThread1 = AfxBeginThread(StartThread1, this );
cThread2 = AfxBeginThread(StartThread2, this );
}
// Terminate thread
void MainChildDlg2::OnStopButton()
{
DWORD lpExitCode1;
DWORD lpExitCode2;
// Retrieves termination status of thread
GetExitCodeThread( cThread1->m_hThread, &lpExitCode1 );
GetExitCodeThread( cThread2->m_hThread, &lpExitCode2 );
hMutex = NULL;
// Terminate thread
if( TerminateThread( cThread1->m_hThread, 0 ) == FALSE )
GetLastError();
if( TerminateThread( cThread2->m_hThread, 0 ) == FALSE )
GetLastError();
cThread1 = NULL;
cThread2 = NULL;
CloseHandle( hMutex );
m_cEditThread1.SetWindowText( "0" );
m_cEditThread2.SetWindowText( "0" );
delete cThread1;
delete cThread2;
}
After the thread stops it doesn't show any memory leak but when I exit the program this is the message that appears:
Detected memory leaks!
Dumping objects ->
thrdcore.cpp(166) : {140} client block at 0x00433140, subtype 0, 112
bytes long.
a CWinThread object at $00433140, 112 bytes long
thrdcore.cpp(166) : {135} client block at 0x00433410, subtype 0, 112
bytes long.
a CWinThread object at $00433410, 112 bytes long
Object dump complete.
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|