-
July 3rd, 2013, 03:25 PM
#1
AfxBeginThread
Something I am not being able to understand. I am using VC2005. In MFC I am creating threads repeatedly. The thread is basically doing nothing. Its an empty block. So, there should not be any memory leak. But I am seeing constant memory increase in the task manager. Here is my code.
In OnInitDialog():
for (;{
AfxBeginThread(testThread, this);
Sleep(50);
}
In some part of the main dlg body:
UINT CTestThreadDlg::testThread(LPVOID pParam)
{
return 0;
}
I also tried doing the following without any luck.
In OnInitDialog():
CWinThread *m_Thread=NULL;
for (;{
if (m_Thread) {
delete m_Thread;
m_Thread=NULL;
}
m_Thread=AfxBeginThread(testThread, this, 0, 0, CREATE_SUSPENDED, NULL);
m_Thread->m_bAutoDelete=FALSE;
m_Thread->ResumeThread();
WaitForSingleObject(m_Thread->m_hThread, INFINITE);
}
Can anybody please explain why its happening and what can be done to make it right?
Thanks in advance.
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
|