Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Top Command

Status
Not open for further replies.

ScottA

Technical User
Jul 10, 2000
21
US
Hello All:

I just found out that linux misrepresents the memory usage with Top. First, is this true? Second, is there a way to fix it.

For example, if I run top and look at the output I see that a certian process's RSS value is like 26M, but if I look there may be 5 threads running with the exact same value. How can I find out what each thread is using?

If this problem is true then, is the total used memory incorrect also?

Thanks [sig][/sig]
 
One thing to bear in mind when looking at memory usage is shared libraries. If a program has been compiled to use, for example, libstdc.so (filename probably spelled incorrectly here), then this will be loaded into memory once. However, it will show up in the memory totals for every program that links to it.

So, for the five or six threads that show 26Mb, most of that memory is likely to be shared memory. This isn't just a Linux "feature" - you will see it on nearly every version of Unix. (At least that I know of.) For example, we have one (non-Linux) server here that has 512Mb of memory, and 2Gb of swap. It runs a big database, and I just totalled memory usage of running processes at around 1.6Gb. (This is a little high - there are some weekly reports that have just started to run that have bumped this up from the normal average of around 800Mb.) The swap space area isn't even being touched.

So, don't worry too much about the memory &quot;usage&quot; being shown by top. It's actually a reflection of how much memory the process has mapped, and includes shared memory for data and libraries. [sig]<p> Andy Bold<br><a href=mailto: > </a><br><a href= > </a><br>"I've probably made most of the mistakes already, so hopefully you won't have to..." Me, most days.[/sig]
 
I have read reports very similar to this in the past. I would like to know of a means to accurately view the memory usage of the system.
 
free.
The /proc (kernel) dir holds all this info.
 
if you use the program &quot;free&quot; it will display a brief memory listing. showing used, free and cached.

linux always tries to totally fill all it's memory. if programs aren't using it all it will try to use the rest as a file cache.

if you really want detailed view of memory do &quot;cat /proc/slabinfo&quot;

just don't ask me how to read it :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top