Alicia
2004-02-10 04:31:15 UTC
Greetings:
I am porting Unix pthread code to Win32, and have not found any thing
equivalent to "pthread_detach".
If I create threads using CreateThread, and never call WaitForSingleObject
or WaitForMultipleObjects for these threads, do I get a memory leak?
Consider the following program, that continuously creates threads, and
then forgets about them. Those created threads exit immediately on
their own. However, if I never join those created threads with a call to
WaitForSingleObject or WaitForMultipleObjects, will any type of memory
leak occur? Will the program continuous store all of the return states of
each thread as it finishes, and never release the data?
// #################################################################
DWORD start (void *data)
{
printf ("Started thread #%d!\n", (int) data);
return 0;
}
int main (int argc, char **argv)
{
HANDLE thread;
int j;
for (j = 0; j < 100000000; j++)
{
thread = CreateThread (NULL, 0, start, (void *) j, 0, NULL);
Sleep (200);
}
return 0;
}
// #################################################################
Thanks in advance.
Alicia.
PS. Please e-mail me back by replacing the "nospam" portion of my e-mail
address with my name "alicia".
I am porting Unix pthread code to Win32, and have not found any thing
equivalent to "pthread_detach".
If I create threads using CreateThread, and never call WaitForSingleObject
or WaitForMultipleObjects for these threads, do I get a memory leak?
Consider the following program, that continuously creates threads, and
then forgets about them. Those created threads exit immediately on
their own. However, if I never join those created threads with a call to
WaitForSingleObject or WaitForMultipleObjects, will any type of memory
leak occur? Will the program continuous store all of the return states of
each thread as it finishes, and never release the data?
// #################################################################
DWORD start (void *data)
{
printf ("Started thread #%d!\n", (int) data);
return 0;
}
int main (int argc, char **argv)
{
HANDLE thread;
int j;
for (j = 0; j < 100000000; j++)
{
thread = CreateThread (NULL, 0, start, (void *) j, 0, NULL);
Sleep (200);
}
return 0;
}
// #################################################################
Thanks in advance.
Alicia.
PS. Please e-mail me back by replacing the "nospam" portion of my e-mail
address with my name "alicia".