checkin
asked on
Pthreads
Hi !
I am trying to use pthreads on Solaris.
I can create a thread that runs sucessfully and from the calling function I issue a pthread_join which returns a success. The problem I have is that while monitoring the memory usage of the process using the top program when the thread is created I see the memory jump up but when the join is issued the memory does not decrease.
I am planning to write a server that will have multiple threads and until I can sort out this issue I can not continue. Does anybody know where I am going wrong ?
I am trying to use pthreads on Solaris.
I can create a thread that runs sucessfully and from the calling function I issue a pthread_join which returns a success. The problem I have is that while monitoring the memory usage of the process using the top program when the thread is created I see the memory jump up but when the join is issued the memory does not decrease.
I am planning to write a server that will have multiple threads and until I can sort out this issue I can not continue. Does anybody know where I am going wrong ?
ASKER
Hi !
Yes I found this too after doing some testing. I ran 2000 threads at one go and then joined them all, I did see the memeory usuage drop. The problem is that Solaris only releases resources back if some other process requires it, thats why with just one or two threads I did not see the memory decrease.
Yes I found this too after doing some testing. I ran 2000 threads at one go and then joined them all, I did see the memeory usuage drop. The problem is that Solaris only releases resources back if some other process requires it, thats why with just one or two threads I did not see the memory decrease.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One way to test this would be to spawn off a thread, have it rejoin, then spawn another. The process size should remain the same as if only one thread had been spawned. So essentially your process size should expand to the accomodate the memory requirements of the largest number of concurrent threads that you had supported up to the current time. Your actual memory usage, however, could be much lower.