simple pthread consumes memory

balazs balazs___@freemail.hu
Fri Sep 22 23:07:00 GMT 2006


Hi - I start a simple pthread and the program consumes about 10 Mbytes of
virtual memory. If I start 10 threads, it consumes 100 Mbytes. I don't know
why this is happening to me. I tried it on two Debian and a 64 bit Ubuntu
machines and the same thing happened to me. Thanks in advance for any help.

Balazs


I compile by:    g++ -lpthread main.cpp

#include <pthread.h>

void* myfunction( void* ptr ) {
	int sum = 0;
	for( int i = 0; i < 2000000000; i++ )
		sum *= i;
}

int main( int argc, char* argv[] ) {
	pthread_t mythread;

	pthread_create( &mythread, 0, &myfunction, NULL );
	pthread_join( mythread, NULL );
}

-- 
View this message in context: http://www.nabble.com/simple-pthread-consumes-memory-tf2320485.html#a6456330
Sent from the gcc - Dev mailing list archive at Nabble.com.



More information about the Gcc mailing list