This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

simple pthread consumes memory


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.


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