using OpenMP occurs memory leak in thread

General OpenMP discussion

using OpenMP occurs memory leak in thread

Postby huangdandan » Thu Jan 17, 2008 8:01 pm

Hello,every guys!
My platform is: MS VC++ 2005, Window XP
I Write a piece of code like fllowing:

bool g_bStopTest = false;
long g_nTimes = 0;

void ThreadOmpLeakTest(void* lp)
{
CTestLeakedOpenMPDlg* pDlg = (CTestLeakedOpenMPDlg*)lp;
int nCount = 0;
#pragma omp parallel
{
while (nCount>10)
{
nCount++;
Sleep(100);
}
}

pDlg->m_strTestTime.Format("Run %d Times",g_nTimes++);
pDlg->SetDlgItemTextA(IDC_EDT_TIMES, pDlg->m_strTestTime);
_endthread();
}

void ThreadTaskCall(void * lp)
{
while (!g_bStopTest)
{
_beginthread(ThreadOmpLeakTest,0,lp);
Sleep(1000);
}

_endthread();
}

void CTestLeakedOpenMPDlg::OnBnClickedBtnStart()
{
g_bStopTest = false;
_beginthread(ThreadTaskCall, 0, this);
}

when the ThreadOmpLeakTest exit will be found some memory leaked,may be 4K bytes. Actaully, this problem has posted
in Intel's site by others,but no people answered.

the attachment is sourcecode of demo,you can complie it in MS VC++ 2005, remember open omp swtich.
Attachments
TestLeakedOpenMP.rar
(43.36 KiB) Downloaded 399 times
huangdandan
 
Posts: 2
Joined: Thu Jan 17, 2008 7:38 pm

Re: using OpenMP occurs memory leak in thread

Postby lfm » Fri Jan 18, 2008 8:20 pm

Are you using the microsoft compiler or the Intel compiler? It appears that you have multiple user threads all creating parallel regions. This isn't necessarily a good idea since it may result in oversubscription. It may be that the user threads are allocating OpenMP data structures that never go away. Also, there is a race condition on the nCount variable, though that probably doesn't matter. A simpler test case might help.
lfm
 
Posts: 135
Joined: Sun Oct 21, 2007 4:58 pm
Location: OpenMP ARB

Re: using OpenMP occurs memory leak in thread

Postby huangdandan » Fri Jan 25, 2008 5:54 am

Yes, I use Intel Complier.
the attachment for demostrate the fact of memory leaked.

I don't know why?

Please tell me crrect way to use OpenMP in thread?

Now, I use a Win32 Cirtical instead of "#progma omp critical"!
huangdandan
 
Posts: 2
Joined: Thu Jan 17, 2008 7:38 pm


Return to Using OpenMP

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 6 guests