Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pthreads

Posted on 1999-07-13
3
Medium Priority
?
312 Views
Last Modified: 2010-04-15
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 ?
0
Comment
Question by:checkin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Expert Comment

by:helver
ID: 1263565
What you're seeing is virtual memory usage, not physical memory usage.  Any time a process requests more memory (using malloc or something similar) and it must expand its used virtually memory, it will maintain this new size until the process dies.  Even though memory malloc'd is eventually freed (thus freeing up physical memory) the size of the process does not decrease.  However, the next time a similar malloc is issued, the process size should not have to increase.

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.
0
 

Author Comment

by:checkin
ID: 1263566
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.
0
 
LVL 2

Accepted Solution

by:
helver earned 200 total points
ID: 1263567
So does that qualify as an acceptable answer?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question