LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-28-2009, 08:40 AM   #1
notepod
LQ Newbie
 
Registered: Sep 2009
Posts: 11

Rep: Reputation: 1
how to see kernel memory in top ?


Hello

I use top command to monitor memory usage on my Debian server.
There is something i don't understand: if i add every "VIRT" field for each process, it's not equal to "Mem: XXX used". (I have 0k used in SWAP).

I'd have expected that "Mem used + Swap used" = "sum(VIRT for each process)". In practice we have:
"Mem used + Swap used" > "sum(VIRT for each process)"
I guess the difference is the kernel's memory ?

Can anyone confirm this ? And how can i see the memory taken by the kernel ?

Thanks a lot !
 
Old 09-28-2009, 09:04 AM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
Quote:
Originally Posted by notepod View Post
if i add every "VIRT" field for each process, it's not equal to "Mem: XXX used". (I have 0k used in SWAP).
They shouldn't be equal. There is a lot included in the total of the VIRT values that is not in either "Mem" or Swap. There is also a lot in "Mem" that is not in any "Virt".

Quote:
In practice we have:
"Mem used + Swap used" > "sum(VIRT for each process)"
I guess the difference is the kernel's memory ?
I expect the reason the difference is in that direction is caching. You probably have very little "memory pressure" so a large fraction of memory is used by caching.

Quote:
And how can i see the memory taken by the kernel ?
One of the important measures of Kernel memory use is the "Slab" line you can find within
cat /proc/meminfo

I think that will typically represent most of the memory in use by the kernel. I don't recall where you can find more detail on kernel memory use. But since the kernel memory use isn't responsible for the big difference you are seeing vs. what you expect, probably you don't need any detail on kernel memory use.
 
Old 09-28-2009, 09:55 AM   #3
notepod
LQ Newbie
 
Registered: Sep 2009
Posts: 11

Original Poster
Rep: Reputation: 1
let's take this /proc/meminfo for example:
http://www.redhat.com/docs/manuals/e...c-meminfo.html

Can you fill the blank ?
MemTotal = MemFree + Buffers + Cached + Slab + ???

btw i don't have a huge difference between "used + swap" and "sum(VIRT)" (resp. 218168 and 213104).
 
Old 09-28-2009, 10:16 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
Quote:
Originally Posted by notepod View Post
Can you fill the blank ?
MemTotal = MemFree + Buffers + Cached + Slab + ???
I don't know if the numbers are available to add up total memory use that way.

In the /proc/meminfo I'm looking at, there is an entry for AnonPages, which is not in the document you linked.

I think AnonPages and Mapped together represent the ordinary memory use of ordinary processes. But when I add things up on my own system

MemTotal < MemFree + Buffers + Cached + Slab + AnonPages + Mapped

even though I think some other things (such as PageTables) belong on the right and I don't know how any of those items on the right might overlap each other and/or be outside of MemTotal, so I don't know why they can add up to more than MemTotal.

Quote:
btw i don't have a huge difference between "used + swap" and "sum(VIRT)" (resp. 218168 and 213104).
As I said earlier, there are large parts of each of those that aren't included in the other. So comparing them has little meaning.
 
Old 09-28-2009, 11:14 AM   #5
notepod
LQ Newbie
 
Registered: Sep 2009
Posts: 11

Original Poster
Rep: Reputation: 1
yes, that's a little sad ...

i will continue to look for a more "mathematic" explanation and if i find anything i'll post it here for other readers ...

thanks
 
Old 09-28-2009, 11:42 AM   #6
krkz
LQ Newbie
 
Registered: Sep 2009
Distribution: Archlinux
Posts: 8

Rep: Reputation: 1
Quote:
Originally Posted by notepod View Post
And how can i see the memory taken by the kernel ?
Hi. Maybe you are looking for something like this:
dmesg | grep Memory
My output is:
Code:
Memory: 509288k/524272k available (1957k kernel code, 14396k reserved, 1680k data, 264k init, 0k highmem)
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What does free memory mean in top? blittrell Linux - Newbie 3 08-05-2009 12:10 PM
To find the process that uses the most memory using top nano2 Linux - Server 2 06-12-2008 10:02 AM
Memory usage using TOP FantaJ Linux - Newbie 2 03-05-2008 12:35 PM
top reports 99% memory used when using a tmpfs damonnew Linux - General 1 01-30-2005 01:51 AM
Top reports > 100% Memory use by X sparky6969 Linux - General 2 07-20-2001 09:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:54 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
Open Source Consulting | Domain Registration