LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 03-13-2009, 03:54 PM   #1
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Rep: Reputation: 31
Question Why doesnt top or free show swap memory usage ?


Hi

I have a laptop with 1GB physical memory and 2GB virtual memory.

I have firefox, several xterms, amarok and more running at a time. When i run the top or the free command it doesnt show anything about the system using any virtual memory, its says "0k used" at the swap space line and the number 0 at the swap line when using the free command.

When i read the top manual page is see that the "VIRT" column is used to display the virtual memory the process is using and when i check the VIRT column it shows 404m in one column and more in another column, yet the top program doesnt display any virtual memory as used.

Can someone please explain whats going on here, i mean, why isnt top or free displaying the amount of virtual memory used ..they just display 0k virtual memory used...

Last edited by exceed1; 03-13-2009 at 03:59 PM.
 
Old 03-13-2009, 04:03 PM   #2
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by exceed1 View Post
1GB physical memory
Maybe that is enough that your system doesn't want to use any swap. Or maybe something is wrong. You haven't given enough info.

Quote:
and 2GB virtual memory.
That is meaningless. So what did you think that means? Why do you think you have 2GB virtual memory?

Quote:
When i read the top manual page is see that the "VIRT" column is used to display the virtual memory the process is using and when i check the VIRT column it shows 404m in one column
VIRT includes several kinds of memory that are neither in physical memory nor in the swap space. So a large number in VIRT doesn't necessarily mean a large amount of physical ram or swap is being used.

Quote:
and more in another column
Do you mean "more in another row"? Otherwise, what you said doesn't seem to mean anything.

Quote:
Can someone please explain whats going on here ?
Only with more information.
 
Old 03-13-2009, 04:41 PM   #3
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

Rep: Reputation: 43
Quote:
Originally Posted by exceed1 View Post
Can someone please explain whats going on here, i mean, why isnt top or free displaying the amount of virtual memory used ..they just display 0k virtual memory used...
It's always good to provide the output from these commands as something for us to refer to. Use code tags around the outputs from: 'free -m' and 'top -b -n 1 | head -15'

Last edited by TBC Cosmo; 03-13-2009 at 04:42 PM. Reason: Added some clarity
 
Old 03-13-2009, 06:42 PM   #4
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
okey. thanks for your answers.

Here is the output from free -m:
Code:
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1002        912         89          0         83        513
-/+ buffers/cache:        315        686
Swap:         1906          0       1906
Now it seems like almost all available physical RAM is used, but not enough to use swap. Usually there is only 16MB left and it seems to stay at that amount of physical RAM no matter how many other programs im starting.

Output from top:
Code:
Tasks: 108 total,   4 running, 104 sleeping,   0 stopped,   0 zombie
Cpu(s): 15.9%us,  1.7%sy,  0.0%ni, 82.0%id,  0.0%wa,  0.2%hi,  0.2%si,  0.0%st
Mem:   1026764k total,   943552k used,    83212k free,    86336k buffers
Swap:  1951888k total,        0k used,  1951888k free,   525720k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 3737 root      20   0  410m  56m 4724 R   27  5.6  31:45.82 Xorg               
13715 exceed    20   0  154m  42m  26m R   19  4.2   0:46.71 amarokapp
And from the top manual page:
Code:
      o: VIRT  --  Virtual Image (kb)
          The  total  amount  of virtual memory used by the task.  It includes
          all code, data and  shared  libraries  plus  pages  that  have  been
          swapped out.

          VIRT = SWAP + RES.
It says the total amount of virtual memory used.. when it says "all code, data and shared libraries".. would that mean all the virtual memory used to store code, data and shared libraries?

Please tell me if you need more information and if so then what kind.
 
Old 03-13-2009, 07:03 PM   #5
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by exceed1 View Post
Please tell me if you need more information and if so then what kind.
Code:
cat /proc/sys/vm/swappiness
Quote:
Originally Posted by exceed1 View Post
Here is the output from free -m:
Notice most of the memory is used by file caching, not by ordinary process memory (686 file caching, 315 ordinary memory use).
Quote:
$ free -m
I don't know how to get a meaningful breakdown of an individual process's virtual memory usage (much less the whole system). But you can see that the two processes you listed have VIRT far in excess of even the sum of RES and SHR. That combined with the lack of use of swap area leaves two possibilities that I know of:

1) Almost all their virtual memory use is "demand zero" memory, meaning the internal memory manager (malloc or equivalent) in the process has allocated virtual address space from the kernel, but hasn't actually used it.

2) Memory mapping large data files but not accessing them.

Either way, for most practical purposes that virtual memory use isn't real.

Quote:
Now it seems like almost all available physical RAM is used, but not enough to use swap. Usually there is only 16MB left and it seems to stay at that amount of physical RAM no matter how many other programs im starting.
As you start other programs, the system uses less memory for file caching and more memory for those processes and doesn't swap anything. That means one of two things:

1) You have a lot of very old data in the file caching memory, so the basic LRU rules cause file caching to be reduced instead of stale process memory.

2) You have swappiness set very low.

Quote:
VIRT = SWAP + RES.
True, but only because the definition of "SWAP" is VIRT minus RES. "SWAP" does not tell you how much swap space is in use.

Quote:
when it says "all code, data and shared libraries".. would that mean all the virtual memory used to store code, data and shared libraries?
It means all virtual address space used for code, data (including "demand zero" that takes no space in physical ram nor swap and non sharable file mappings, that might take no space in ram and anyway takes none in swap) and shared libraries (and other shared mappings, that also might not take space in ram, yet still never take space in swap).

Last edited by johnsfine; 03-13-2009 at 07:21 PM.
 
Old 03-13-2009, 07:11 PM   #6
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
Here is the output from that command:
Code:
$ cat /proc/sys/vm/swappiness
60
 
Old 03-13-2009, 07:26 PM   #7
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by johnsfine View Post
As you start other programs, the system uses less memory for file caching and more memory for those processes and doesn't swap anything. That means one of two things:
I was editing the above into my post while you gave the answer about swappiness. You have the default swappiness. So that eliminates one of those two meanings, leaving only the meaning that you have a lot of very old data in file caching that the kernel discards whenever it needs memory.
 
Old 03-13-2009, 07:28 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,491

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
Quote:
Originally Posted by exceed1 View Post
Now it seems like almost all available physical RAM is used, but not enough to use swap. Usually there is only 16MB left and it seems to stay at that amount of physical RAM no matter how many other programs im starting.
Good isn't it ?.
That's the way it's designed - the user (you ) doesn't have to worry about it because memory management in the kernel does.
Usually stated as "you paid for all the memory, why not use it all". Buffers and (disk/page) cache are used to fill the "unused" memory and released as programs demands more storage. This is the line you should be concentrating on - it adjusts for cache/buffer usage.
Code:
-/+ buffers/cache:        315        686
BTW you seem to be confusing the use of "virtual". In one context you use it to mean "swap space", and in another you quote the definition from top of "VIRT". Whilst not incorrect, it pays to keep them separate - especially in the one post ...
 
Old 03-13-2009, 07:38 PM   #9
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by syg00 View Post
Good isn't it ?.
Maybe.

Quote:
That's the way it's designed
Probably, but I think you'll agree this is unusual. There are 104 sleeping tasks. Usually the kernel will decide some pages used by the tasks that have been sleeping longest are so stale that it is better to swap them out than reduce the file caching. In this case that hasn't happened.

Quote:
Usually stated as "you paid for all the memory, why not use it all". Buffers and (disk/page) cache are used to fill the "unused" memory and released as programs demands more storage.
That certainly answers the main question here. But it brings up that more subtle secondary question. Why does the kernel continue to think the most stale pages in sleeping tasks are less stale than the most stale pages in the file cache? This hints that the file cache still contains some files that were used only once at boot up, which would imply the total of all files ever read since the completion of boot up is less than the 600m in file cache. That's a pretty lightly used system. If this system has read more files than that, then something isn't working as designed.

Last edited by johnsfine; 03-13-2009 at 07:41 PM.
 
Old 03-13-2009, 08:12 PM   #10
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Quote:
Originally Posted by johnsfine View Post
Probably, but I think you'll agree this is unusual.
I've noticed a number of these odd memory posts lately. (Just info for thought.)

Quote:
There are 104 sleeping tasks. Usually the kernel will decide some pages used by the tasks that have been sleeping longest are so stale that it is better to swap them out than reduce the file caching. In this case that hasn't happened.
I don't know about this. I've got 140 sleeping tasks on my Lenny machine at the moment, and no used swap. (Swappiness is also 60)
Code:
Tasks: 141 total,   1 running, 140 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,  0.1%sy,  0.0%ni, 99.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3888324k total,   794944k used,  3093380k free,   167248k buffers
Swap:   987956k total,        0k used,   987956k free,   329056k cached
Don't know if this contributes to the discussion or not, but just thought I'd throw it in.
 
Old 03-13-2009, 08:31 PM   #11
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by Quakeboy02 View Post
I've got 140 sleeping tasks on my Lenny machine at the moment, and no used swap. (Swappiness is also 60)
But if I'm reading that right, you also have 4GB of physical ram with both tiny use of ram by processes and tiny use of ram by file caching. So obviously your system shouldn't be swapping stale pages out of sleeping processes. It isn't even dropping stale pages out of file cache. You never read enough files to even fill the file cache.

The is easier to understand than repeatedly dropping stale pages from file cache without ever swapping stale pages from sleeping tasks.
 
Old 03-13-2009, 11:13 PM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,491

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
Quote:
Originally Posted by johnsfine View Post
The is easier to understand than repeatedly dropping stale pages from file cache without ever swapping stale pages from sleeping tasks.
I don't see why you think that.
Swapping is slow, and expensive - by definition you have to swap out, then (potentially) also swap back in at sometime. Swap is also only used for dirty anonymous pages - i.e. those malloc'd and actually used by the process. On the other hand, unchanged (disk) cached pages are already on disk (by definition), so they never need to be written back - they are simply dropped from the active q and reused elsewhere.
Note that all (any) of this is only done if there is pressure on memory - it's too expensive to continually run the page q's moving pages back and forth. This is a lazy deallocation - pages may appear still allocated to defunct tasks, but will normally only be moved to the free q if needed.
 
Old 08-03-2009, 09:04 PM   #13
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Mageia Studio-13.37 Kubuntu.
Posts: 3,325
Blog Entries: 33

Rep: Reputation: 199Reputation: 199
Hi, What could we use to benchmark this?

Do any of you have a suit of programs or app you use to stress test

a Linux system?

Cheers Glenn

<edit>
OK, I know a few stand alone, like memtest86+, But I'm thinking of gui mode many tasks at once.
</edit>

Last edited by GlennsPref; 08-03-2009 at 09:06 PM.
 
Old 08-03-2009, 09:11 PM   #14
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

Rep: Reputation: 43
Not a benchmark tool, but to tax a system - the aptly named Stress Tool
 
Old 08-03-2009, 09:14 PM   #15
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by GlennsPref View Post
What could we use to benchmark this?
I don't think your question is related enough to tack onto the end of this old thread. You should have started a new thread.

Of course in a new thread you couldn't just use the word "this" that way and expect people to understand. You would need to specify what you mean.

However, the same is true even tacked on an old thread. Your use of the word "this" doesn't quite work. "this" must be something related to the topic discussed in the thread above. I can think of several things in this thread "this" might refer to that someone might want to benchmark. No one of those stands out as the most likely meaning.
 
  


Reply

Tags
benchmarking


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TOP command: calculation of memory usage samiralmousawi Linux - Server 7 07-29-2008 04:16 PM
Reported memory usage doesn't tally with top geokker Linux - Server 2 04-04-2008 04:09 PM
Memory usage using TOP FantaJ Linux - Newbie 2 03-05-2008 01:35 PM
How do I read the memory usage in top? jaakkop Linux - Hardware 1 03-10-2006 11:12 AM
Memory usage reported using TOP Kdiver58 Linux - Newbie 1 02-03-2003 02:31 PM


All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration