c - pthread_create memory leak? -
whenever I run Valgrind on my program, it is saying that I have lost memory probably where I pthread_create it is said. I am trying to follow the guidelines on
and various other websites, which Google gave me, but nothing has worked. . So far, I have tried to invoke a separate pthread_attr_t to join the thread, call pthread_detach on each thread and call pthread_exit ()
PTHREAD_CREATE_DETACHED -
Pthread_attr_t attr; Pthread_attr_init (& amp; attr); Pthread_attr_setdetachstate (& amp; ethern, PTHREAD_CREATE_DETACHED); Pthread_create (& amp; c_udp_comm, & amp; etr, udp_comm_thread, (Zero *) this); Pthread_create (and drive, & amp; atri, driving_thread, (zero *) this); Pthread_create (& amp; Update, & amp; ether; update_server_thread (Zero *) this); I think I can get involved in wrong and coded the next one ... I am going and they have all the threads in an array so that they are just loop for. But I do not have all those in the array, so I tried to change it to work. Please tell me if I have done it wrong.
Zero * status; Pthread_attr_t attr; Pthread_attr_init (& amp; attr); Pthread_attr_setdetachstate (& amp; Authr; PTHREAD_CREATE_JOINABLE); Pthread_create (& amp; c_udp_comm, & amp; etr, udp_comm_thread, (Zero *) this); Pthread_create (and drive, and atri, driving_read, (zero *) this); Pthread_create (& amp; Update, & amp; ether; update_server_thread (Zero *) this); Pthread_join (c_udp_comm, and status); Pthread_join (drive, and position); Pthread_join (updates, and status); Trying pthread_detach - pthread_create (& c_udp_comm, void, udp_comm_thread, (zero *) this); Pthread_create (and drive, tap, driving_read, (zero *) this); Pthread_create (& amp; update, tap, update_server_thread (zero *) this); Pthread_detach (c_udp_comm); Pthread_detach (drive); Pthread_detach (updated);
Trying pthread_exit -
pthread_create (& c_udp_comm, zero, udp_comm_thread, (zero *) this); Pthread_create (and drive, tap, driving_read, (zero *) this); Pthread_create (& amp; update, tap, update_server_thread (zero *) this); Pthread_exit (zero); Anybody can help me find out why any of this is working I would be very grateful.
"itemprop =" text "> glibc does not freeze the thread stack on the exit of the thread; It caches them to reuse them, and only when the quantity of the cache grows larger, thus it always "leaks" some memory.
Comments
Post a Comment