public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* RE: memory leak??
@ 2004-03-20  0:52 phuong nguyen
  0 siblings, 0 replies; 5+ messages in thread
From: phuong nguyen @ 2004-03-20  0:52 UTC (permalink / raw)
  To: Arnett, Don L., pthreads-win32

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




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: memory leak??
  2004-03-24  7:05   ` Ross Johnson
@ 2004-03-24 13:42     ` Ed Hume
  0 siblings, 0 replies; 5+ messages in thread
From: Ed Hume @ 2004-03-24 13:42 UTC (permalink / raw)
  To: rpj; +Cc: pthreads-win32

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?
>
> Ross
>
> 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;
>>>
>>>     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().
>
>
>
>

-- 
Regards,

Ed Hume
Hume Integration Software           http://www.hume.com/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: memory leak??
  2004-03-20  9:07 ` Philipp Klaus Krause
@ 2004-03-24  7:05   ` Ross Johnson
  2004-03-24 13:42     ` Ed Hume
  0 siblings, 1 reply; 5+ messages in thread
From: Ross Johnson @ 2004-03-24  7:05 UTC (permalink / raw)
  To: pthreads-win32

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?

Ross

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: memory leak??
  2004-03-19 21:01 Arnett, Don L.
@ 2004-03-20  9:07 ` Philipp Klaus Krause
  2004-03-24  7:05   ` Ross Johnson
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Klaus Krause @ 2004-03-20  9:07 UTC (permalink / raw)
  To: Arnett, Don L.; +Cc: pthreads-win32

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* memory leak??
@ 2004-03-19 21:01 Arnett, Don L.
  2004-03-20  9:07 ` Philipp Klaus Krause
  0 siblings, 1 reply; 5+ messages in thread
From: Arnett, Don L. @ 2004-03-19 21:01 UTC (permalink / raw)
  To: pthreads-win32


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-03-24 13:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-20  0:52 memory leak?? phuong nguyen
  -- strict thread matches above, loose matches on Subject: below --
2004-03-19 21:01 Arnett, Don L.
2004-03-20  9:07 ` Philipp Klaus Krause
2004-03-24  7:05   ` Ross Johnson
2004-03-24 13:42     ` Ed Hume

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