Nadav Har'El wrote:
> On Thu, Mar 14, 2002, Isaac Aaron wrote about "pthreads question":
> 
>>----------------------------------------- (on server-express.q-bytes.com)
>>
>>This mail was scanned by Trend Micro InterScan VirusWall when leaving Quality Bytes
>>
> 
> Agggh!!! What an ugly mailer you're using :(
> 
> 
>>This is my example of pthread not releasing memory resources when the thread
>>function exits (I would REALLY like to have that memory back).
>>
> 
> Please read the manuals of pthread_detach() and maybe pthread_join().
> Hopefully that would fix your problem.
> 
> 

1. I ran up the example and could not reproduce the problem. After the 
programe/threads exited, all virtual memory was returned. Probably, usleep() was 
not honoured on my system (PII 266 MHz) as documented.
2. Threads under Linux are implemented as processes, so that if they don't show 
up any more under ps, they're really gone.
3. According to the GNU C library documentation, if you fail to join to a 
joinable thread, as a result of the parent prematurely dying, you should get the 
results you saw. Because the threads are Linux processes, they are zombies, 
which show up as unterminated processes, but don't actually hold real resources.
4. pthread_detach merely runs the threads (under Linux) as independent 
processes, which always return their virtual memory on termination.

So, checkout pthread_join and maybe pthread_detach!

Regards,

DAF


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to