This is the mail archive of the pthreads-win32@sourceware.org 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]

Memory leak with detached threads


Hi all,
   I found a memory leak working with detached threads.
   I just made a simple C code to demonstrate where I have the memory leak.

Running the attached C code I saw about 4KB of memory leak every 20 iteration.

I'm using pthreads-dll-2005-03-08.

   Could you tell me if I'm wronging something or if it is a bug?
   Thanks in advance
      giu

--
-----------------------------------------------------------------
Giuliano Catrambone
Director, Professional Services

Open source projects:
http://sourceforge.net/projects/catralibraries/
http://sourceforge.net/projects/openstreaming/

CatraSoftware:
Home page: http://www.catrasoftware.it

Streaming page:
http://www.catrasoftware.it/Streaming/CatraStreamingPlatform.htm

Mobile +39.393.8816655
Fixed: +39.02.90377228
Skype: Catrambone Giuliano
msn: giulianocatrambone@hotmail.com
Jabber: giuliano.catrambone@Jabber.org
Yahoo: giuliano.catrambone
-----------------------------------------------------------------


#include <iostream>
#include <pthread.h>
#include <windows.h>

void *runFunction (void *pvPThread)

{

	std:: cout << "Inside the thread" << std:: endl;

	Sleep (300);


	return (void *) NULL;

}

int main ()

{
	pthread_t			_pThread;
	pthread_attr_t		_pThreadAttribute;


	for (long lIndex = 0; lIndex < 1000; lIndex++)
	{
		std:: cout << "Index: " << lIndex << std:: endl;

		std:: cout << pthread_attr_init (&_pThreadAttribute) << std:: endl;

		std:: cout << pthread_attr_setdetachstate (&_pThreadAttribute, PTHREAD_CREATE_DETACHED)
			<< std:: endl;

		std:: cout << pthread_create (&_pThread, &_pThreadAttribute, runFunction, NULL) << std:: endl;

		// std:: cout << pthread_join (_pThread, &pvStatus) << std:: endl;

		std:: cout << pthread_attr_destroy (&_pThreadAttribute) << std:: endl;

		Sleep (300);
	}

	Sleep (1000 * 1000);

	return 0;
}


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