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.
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.