This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: memory leak??


Just a thought
	pthread_t *poThread;
	poThread = (pthread_t*)calloc(1,sizeof(pthread_t));
	pthread_create(poThread,NULL,pvDoSomething,NULL);

why not
	pthread_t poThread;
	pthread_create(&poThread,NULL,pvDoSomething,NULL);


-----Original Message-----
From:	pthreads-win32-owner@sources.redhat.com on behalf of Arnett, Don L.
Sent:	Sat 3/20/2004 2:31 AM
To:	pthreads-win32@sources.redhat.com
Cc:	
Subject:	memory leak??

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;
}





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]