This is the mail archive of the 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??

You should not pay much attention to the Task Manager. The "Mem Usage" statistic includes freed memory that has yet to be harvested by the OS. The "VM Size" is a better statistic for analyzing leakage, but you should not try to meter single calls, there is too much other activity. Do the calls once to get initialization done, take a snapshot of VM Size, and then do the calls in a loop and do it some odd number of thousands of times such as 7000 and see if you change VM size by 7000 times some amount.

Ross Johnson wrote:

There's nothing that big in the library and no arrays of objects that big etc that I recall. What exactly is included in the size that Task Manager reports? Could it be pages of the DLL itself that have been loaded into memory? The DLL is only 52k and half of it could easily have been loaded after the first pthread_create() call.

What happens if you put the getchar() ... getchar() block in a loop - do you get 28k added each time?


Philipp Klaus Krause wrote:

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;


    poThread = (pthread_t*)calloc(1,sizeof(pthread_t));


    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().

-- Regards,

Ed Hume
Hume Integration Software 

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