Here is the source code of my C++/ME app. When I run it I can use "Windows Task Manager" to see that thread HANDLEs are leaking.
If I put something that is not using Open MP into the ThreadProc no HANDLEs will be leaked.
I realize that what happens is: Omp creates unmanaged threads inside a managed thread (i.e. System::Threadi ng::Thread). I just have very little idea about what could be wrong with it. If somebody will try to reproduce this, I am currently using VS2005.
Thanks for all your comments and suggestions.
Code:
#include "stdafx.h"
#include <omp.h>
public __gc class TestClass
{
public:
void ThreadProc()
{
int sum = 0;
#pragma omp parallel for reduction(+:sum)
for ( int i = 0; i < 10000; i++ )
{
sum += i;
}
System::Console::WriteLine( sum.ToString() );
}
};
int main()
{
for (;;)
{
TestClass __gc * o = __gc new TestClass();
System::Threading::Thread __gc * t = __gc new System::Threading::Thread(
__gc new System::Threading::ThreadStart( o, &TestClass::ThreadProc ) );
t->Start();
System::Threading::Thread::get_CurrentThread()->Sleep( 100 );
}
}
I realize that what happens is: Omp creates unmanaged threads inside a managed thread (i.e. System::Threadi ng::Thread). I just have very little idea about what could be wrong with it. If somebody will try to reproduce this, I am currently using VS2005.
Thanks for all your comments and suggestions.
Comment