Command to check memory used or consumed by OS kernel

I am trying to check how much memory is consumed by OS Kernel using below command, Is this the correct command that I'm using

grep Slab /proc/meminfo

Output : Slab: 3106824 kB
IF I convert KB to GB, It means 2.9 GB of RAM is consumed

Below details for reference

  uname -a (6.8 santiago)
2.6.32-696.1.1.el6.x86_64 #1 SMP Tue Mar 21 12:19:18 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

According to this document this is not (quite) the correct command. To quote the linked explanation:

Note that "kernel" isn't a monolithic process. In fact the "kernel" consists of several processes, depending on how the system is configured, what it is doing, how much memory it has installed and perhaps a few other things. So it is difficult to point to one certain place and declare it to be the answer. The value you found is arguably part of the answer but if it is depends on what exactly the question is.

Can you tell us what exactly you want, so that maybe we can find some better solution?

I hope this helps.

bakunin

Hi Bakunin,

I have many application running on LINUX box, RAM allocated on this box is 15GB
I want to know how much memory is consumed by Applications and OS

              total        used       free     shared    buffers     cached
Mem:            15G         14G       627M       932K       1.4G       916M
-/+ buffers/cache:        12G       2.9G
Swap:           9G          898M       9.1G

From application level only 12 GB RAM is allocated out of it only 8 GB RAM is consumed currently

But I'm unable to figure out how much RAM is consumed by OS on an average?
If I have a margin of how much RAM is consumed to OS then in future if I need to add any new software/app I can recommend for extra RAM in LINUX BOX, hope you understand

OK, now we're talking.

From the output you provided i read it like this:

You have 15G or RAM, of which ~14G are in (various) use, ~650M are unused. Of the 14G of used RAM ~2.5G are used for buffers and cache, leaving ~11.5G for kernel and applications. When you say ~8G are used for applications that would leave ~3.5G to the kernel. I don't know the Linux kernel well enough to say if the file cache is included in this figure or not.

You can check the memory footprint of running processes by using the -o vsz parameter to the ps -command (SystemV-version). i.e.

ps -Ao vsz,args

will show all processes with the allocated memory (virtual+physical, in KB) and the command lines to invoke them. You need to add the shared memory segments which you can find out about with the ipcs command:

ipcs -m

to get the complete memory used by applications.

Refer to the man pages of the named commands for details.

I hope this helps.

bakunin

1 Like

Thanks for the response but The commands which you have provided does meet my need.

My requirement was to check only RAM (not virtual memory) consumed by OS kernel or allocated to OS kernel

Is this possible by using below command
grep Slab /proc/meminfo