From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14376 invoked by alias); 20 Mar 2004 09:07:07 -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 14325 invoked from network); 20 Mar 2004 09:07:03 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.186) by sources.redhat.com with SMTP; 20 Mar 2004 09:07:03 -0000 Received: from [212.227.126.162] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1B4cRX-0003p3-00; Sat, 20 Mar 2004 10:06:59 +0100 Received: from [80.139.93.212] (helo=spth.de) by mrelayng.kundenserver.de with asmtp (TLSv1:RC4-MD5:128) (Exim 3.35 #1) id 1B4cRX-00076H-00; Sat, 20 Mar 2004 10:06:59 +0100 Message-ID: <405C09A8.10403@spth.de> Date: Sat, 20 Mar 2004 09:07:00 -0000 From: Philipp Klaus Krause User-Agent: Mozilla Thunderbird 0.5 (X11/20040318) MIME-Version: 1.0 To: "Arnett, Don L." CC: pthreads-win32@sources.redhat.com Subject: Re: memory leak?? References: <759C12D9893C354785F7FFE43B4155000B34F1@omacex06.corp.westworlds.com> In-Reply-To: <759C12D9893C354785F7FFE43B4155000B34F1@omacex06.corp.westworlds.com> X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:69aec7263999a7b7d9800f1e5ea05378 X-SW-Source: 2004/txt/msg00038.txt.bz2 Arnett, Don L. schrieb: > I'm new to using pthreadsWin32. According to the TaskMgr display this program is using about 28K more memory at the second getchar() than it was at the first getchar(). I found a couple of discussions of memory leaks in the list archives and it usually was a programmer problem, but I don't see what I'm missing. Thanks for any input. > > #include > #include > #include > > void *pvDoSomething(void *poThreadArgs); > > int main(int argc, char* argv[]) { > > pthread_t *poThread; > > getchar(); > > poThread = (pthread_t*)calloc(1,sizeof(pthread_t)); > pthread_create(poThread,NULL,pvDoSomething,NULL); > pthread_detach(*poThread); > > free(poThread); > > getchar(); > > return 0; > } > > void *pvDoSomething(void *poThreadArgs) { > return NULL; > } > > The created thread does not necessarily run and exit immidiately. It might still exist when you reach the second getchar().