public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Philipp Klaus Krause <pkk@spth.de>
To: "Arnett, Don L." <DLArnett@west.com>
Cc: pthreads-win32@sources.redhat.com
Subject: Re: memory leak??
Date: Sat, 20 Mar 2004 09:07:00 -0000	[thread overview]
Message-ID: <405C09A8.10403@spth.de> (raw)
In-Reply-To: <759C12D9893C354785F7FFE43B4155000B34F1@omacex06.corp.westworlds.com>

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 <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> 
> 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().

  reply	other threads:[~2004-03-20  9:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-19 21:01 Arnett, Don L.
2004-03-20  9:07 ` Philipp Klaus Krause [this message]
2004-03-24  7:05   ` Ross Johnson
2004-03-24 13:42     ` Ed Hume
2004-03-20  0:52 phuong nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=405C09A8.10403@spth.de \
    --to=pkk@spth.de \
    --cc=DLArnett@west.com \
    --cc=pthreads-win32@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).