![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| memory leak? | lenna | IP Networking | 2 | 05-25-2009 07:35 AM |
| Memory leak in pthread | mindTeaser | UNIX for Advanced & Expert Users | 4 | 05-18-2009 02:30 AM |
| Memory leak of fork() | whererush | High Level Programming | 7 | 05-11-2006 12:51 PM |
| about virtual memory and memory leak | shriashishpatil | High Level Programming | 4 | 02-20-2006 11:31 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I have this code...
#include <stdio.h> #include <iostream> #include <pthread.h> static void* cliente(void *datos); int main() { pthread_attr_t tattr; int ret; size_t size = PTHREAD_STACK_MIN + 0x0100; ret = pthread_attr_init(&tattr); ret = pthread_attr_setstacksize(&tattr, size); ret= pthread_attr_setdetachstate(&tattr,PTHREAD_CREATE_JOINABLE); ret=0; pthread_t mythread[401]; while(ret<400) { int error=pthread_create((pthread_t *)&mythread[ret],&tattr,cliente,NULL); if(error==0)pthread_detach((pthread_t)mythread); ret++; } while(true) {} } static void* cliente(void *datos) { char *buff=(char *)malloc(100000); sleep(15); free(buff); buff=NULL; pthread_exit(NULL); } When the code finishes I can observe that the virtual memory(report) in the creation of the threads is not liberated after doing a detach, even the memory(report) reserved also... any body knows this problem??? TIA |
| Bookmarks |
| Tags |
| c++, leak, pthread, pthread_create, pthread_detach |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|