This is the mail archive of the
mailing list for the pthreas-win32 project.
Re: cleaning of memory in pthread_create
- From: Ross Johnson <rpj at ise dot canberra dot edu dot au>
- To: pankaj bathwal <pbathwal at yahoo dot com>
- Cc: pthreads-win32 at sources dot redhat dot com
- Date: Tue, 10 Sep 2002 22:14:29 +1000
- Subject: Re: cleaning of memory in pthread_create
- Organization: University of Canberra, DMT, xISE
- References: <email@example.com>
- Reply-to: rpj at ise dot canberra dot edu dot au
pankaj bathwal wrote:
This is regarding freeing of resource and cleaning of
memory allocated when "pthread_create" is called.
Most of my memory leaks tool says 'memory leak of 120
bytes allocated by calloc in "ptw32_new.c"'.
Is there any call that will free memory and resources?
Or there is some other way?
In your code below you have the comment about pthread_join(). Can you
All threads are joinable by default, so your thread's struct won't be
freed unless you either join the thread, or make the thread detached
before it exits.
See the PTHREAD_CREATE_DETACHED attribute and the
This is my sample code.
static int washere = 0;
void * func(void * arg)
washere = 1;
std::cout<<"Inside The THREAD "<<std::endl;
assert(pthread_create(&t, NULL, func, NULL) == 0);
/* A dirty hack, but we cannot rely on pthread_join
primitive test. */
assert(washere == 1);
std::cout<<"Out side the THREAD "<<std::endl;
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost