The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-08-2008
laurovalente laurovalente is offline
Registered User
 

Join Date: May 2008
Posts: 2
Smile Ok found it!

Hello all!

I found the cause for it..

Quote:
Note - When there is no explicit synchronization to prevent it, a newly created, detached thread can die and have its thread ID reassigned to another new thread before its creator returns from pthread_create(). For nondetached (PTHREAD_CREATE_JOINABLE) threads, it is very important that some thread join with it after it terminates -- otherwise the resources of that thread are not released for use by new threads. This commonly results in a memory leak. So when you do not want a thread to be joined, create it as a detached thread.
(from Further Threads Programming:Thread Attributes (POSIX))

When i initialized the threadattr whit the parameter PTHREAD_CREATE_DETACHED there was no memory leak anymore!
!!!!!



*just to remember that this socket implementation is not a good one for producing, since it creates one thread per each new connection accepted...
The best way to implemented is to limit a maximum number of connections.
Reply With Quote