Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Win32 doesn't have zombie thread issue?

Just know if we call the pthread_create with default pthread_attr_t, then Posix will keep the exited thread information for other thread to query it, there is zombie thread leak if we didn't call pthread_join.

But as I know, on Windows platform, you doesn't need to call WaitForSingleObject or GetExitCodeThread after an thread existed.

So how Win32 handle zombie thread issue, will there resource leak?

like image 845
ZijingWu Avatar asked Mar 11 '14 07:03

ZijingWu


1 Answers

On Windows, threads are kernel objects that are referenced from user mode by HANDLEs. One property of a kernel object is that it "remains in memory as long as at least one object handle exists."

If you do not call CloseHandle on your thread handle(s), you will leak the kernel object.

like image 198
Aaron Klotz Avatar answered Oct 22 '22 05:10

Aaron Klotz