From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28114 invoked by alias); 10 Sep 2002 12:13:28 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 28107 invoked from network); 10 Sep 2002 12:13:27 -0000 Received: from unknown (HELO real.ise.canberra.edu.au) (137.92.140.34) by sources.redhat.com with SMTP; 10 Sep 2002 12:13:27 -0000 Received: from ise.canberra.edu.au (special.ise.canberra.edu.au [137.92.140.39]) by real.ise.canberra.edu.au (8.11.6/8.11.6) with ESMTP id g8ACDLk26292; Tue, 10 Sep 2002 22:13:21 +1000 Message-ID: <3D7DE225.7070809@ise.canberra.edu.au> Date: Tue, 10 Sep 2002 05:13:00 -0000 From: Ross Johnson Reply-To: rpj@ise.canberra.edu.au Organization: University of Canberra, DMT, xISE User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020408 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pankaj bathwal CC: pthreads-win32@sources.redhat.com Subject: Re: cleaning of memory in pthread_create References: <20020910114509.73572.qmail@web14508.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002/txt/msg00095.txt.bz2 pankaj bathwal wrote: > Hi, > 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? Hi Pankaj, In your code below you have the comment about pthread_join(). Can you elaborate? 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 pthread_attr_setdetachstate() function. Regards. Ross > > Regards > > Pankaj > > > This is my sample code. > > > static int washere = 0; > > void * func(void * arg) > { > washere = 1; > std::cout<<"Inside The THREAD "< return 0; > } > > int main() > { > pthread_t t; > > assert(pthread_create(&t, NULL, func, NULL) == 0); > > /* A dirty hack, but we cannot rely on pthread_join > in this > primitive test. */ > Sleep(2000); > assert(washere == 1); > std::cout<<"Out side the THREAD "< return 0; > } > > > __________________________________________________ > Yahoo! - We Remember > 9-11: A tribute to the more than 3,000 lives lost > http://dir.remember.yahoo.com/tribute