I'm not sure if this is usual or not...
I spawn a new thread like this:
Code:
if(pthread_create(&unused_id, NULL, chat_stream, NULL) <0)
die("pthread_create() failed for stream");
After executing the size of my process (monitored with top) is 4k larger than before. In chat_stream, this thread is immitiatly exited again:
Code:
void *chat_stream(void *unused)
{
pthread_exit(0);
}
But the size of the process is still 4k larger. So after spawning a few hundred threads, it takes a ****load of memory. Why that?
The problem is, when I assign a lot of data to this thread like this:
Code:
void *chat_stream(void *unused)
{
char foobar[99999999999]
pthread_exit(0);
}
then all this data isn't freed either. At least top does not decrease the size after exiting a thread. Is this usual and just an issue of top or is something wrong with my code?