G
Guest
Hello,
I'm trying to use the command "#pragma omp parallel for" within a thread but
each thread that is created (and stopped again) produces a memory leak of
about 44kB.
If the entry for "Stack Reserver Size" in
Properties->ConfigurationsProperties->Linker->System is increased, the memory
leak grows up to 10MB and more dependent on the stack reserve size.
Below is a code sample where 100 threads are iteratively created and
stopped, each time leading to the described memory leak.
I've tested the code on Intel dual and quad core processors.
Any help is highly appreciated
#include <Windows.h>
#include <process.h>
#include <cstdio>
#include <omp.h>
unsigned int __stdcall cThreadProc(void* param)
{
Sleep(3000);
#pragma omp parallel for
for (int y=0; y<3000; y++){}
return 0;
}
int main(int argc, char* argv[])
{
for (int k = 0; k < 100; k++)
{
unsigned attr = 0;
HANDLE handle = (HANDLE)_beginthreadex(NULL, 0, cThreadProc, 0,
CREATE_SUSPENDED, &attr);
int prio = GetThreadPriority(GetCurrentThread());
SetThreadPriority(handle, prio);
fprintf(stdout, "begin thread\n");
ResumeThread(handle);
WaitForSingleObject(handle, INFINITE);
CloseHandle(handle);
}
return 0;
}
I'm trying to use the command "#pragma omp parallel for" within a thread but
each thread that is created (and stopped again) produces a memory leak of
about 44kB.
If the entry for "Stack Reserver Size" in
Properties->ConfigurationsProperties->Linker->System is increased, the memory
leak grows up to 10MB and more dependent on the stack reserve size.
Below is a code sample where 100 threads are iteratively created and
stopped, each time leading to the described memory leak.
I've tested the code on Intel dual and quad core processors.
Any help is highly appreciated
#include <Windows.h>
#include <process.h>
#include <cstdio>
#include <omp.h>
unsigned int __stdcall cThreadProc(void* param)
{
Sleep(3000);
#pragma omp parallel for
for (int y=0; y<3000; y++){}
return 0;
}
int main(int argc, char* argv[])
{
for (int k = 0; k < 100; k++)
{
unsigned attr = 0;
HANDLE handle = (HANDLE)_beginthreadex(NULL, 0, cThreadProc, 0,
CREATE_SUSPENDED, &attr);
int prio = GetThreadPriority(GetCurrentThread());
SetThreadPriority(handle, prio);
fprintf(stdout, "begin thread\n");
ResumeThread(handle);
WaitForSingleObject(handle, INFINITE);
CloseHandle(handle);
}
return 0;
}