-2

As all know in Linux machines we have RAM memory and swap memory.

My first question is:

What the reason that the swap memory is increasing – because high level of RAM usage or something else?

Second - is it possible to verify how much memory a process holds?

Example from top command:

Is it possible to calculate how much memory the watchdog process takes ( as described on the top view ) ?

 Tasks: 107 total,   1 running, 106 sleeping,   0 stopped,   0 zombie
 Cpu(s):  0.8%us,  0.5%sy,  0.0%ni, 98.0%id,  0.5%wa,  0.0%hi,  0.1%si,  0.0%st
 Mem:   2075440k total,  2011396k used,    64044k free,   120452k buffers
 Swap:  4192924k total,  1554096k used,  2638828k free,  1418852k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                  
 1 root      15   0  2160  600  544 S  0.0  0.0   1:00.91 init                                                                                                                                                      
 2 root      RT  -5     0    0    0 S  0.0  0.0   0:04.50 migration/0                                                                                                                                               
 3 root      34  19     0    0    0 S  0.0  0.0   0:00.16 ksoftirqd/0                                                                                                                                               
 4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.01 watchdog/0     
Konrad Gajewski
  • 1,498
  • 3
  • 15
  • 29
maihabunash
  • 443
  • 1
  • 11
  • 25
  • why I get -1 ? , what it is wrong with my question? – maihabunash Jun 10 '15 at 08:20
  • Press shift-M to sort `top` by memory usage. – Michael Hampton Jun 10 '15 at 12:57
  • @maihabunash If you hover your cursor over the downvote button, it shows the standard reason for downvotes. – Jenny D Jun 15 '15 at 08:29
  • @maihabunash For one thing, you show clearly that you know that there are two kinds of memory. But then you ask about "how much memory a process holds", which suggests you don't understand that there isn't just one resource that can be described as "memory". – David Schwartz Jun 15 '15 at 09:35

3 Answers3

0

If a significant amount of swap is in use (more than just a few MB) then the system is indeed in a memory crunch - your example shows such case - the system typically becomes sluggish in such conditions.

A small amount may be normal, typically indicating memory pages swapped out (during a memory crunch which happened sometimes in the past) which weren't needed since (from sleeping processes, for example).

Calculating the memory used by a process should be done with care - it may not always be relevant for a memory crunch situation - some/all of the memory it uses could actually be swapped out and not directly contributing to the situation (debatable).

Also pointing to the top memory chewing process may be inappropriate for some systems (for example dedicated web servers) - the culprit could be a high number of small memory footprint processes.

Dan Cornilescu
  • 327
  • 4
  • 10
  • To be clear: high swap usage is not the cause of poor performance. Rather, IO churn caused by pages being swapped in and out is the cause of the poor performance. – EEAA Jun 10 '15 at 18:00
0

What the reason that the swap memory is increasing – because high level of RAM usage or something else?

Yes, High level of RAM usage

Second - is it possible to verify how much memory a process holds?

Most of the methods are indicative to find out how much memory a process holds. There is no accurate way of measuring this as lot of factors add to it, for example 1. shared memory 2. in physical mem or in swap etc...Some of ways to get an idea is

pmap -x <pid>

or

pmap -d <pid>

Crude way of looking at it is

/proc/<pid>/smaps
0

My first question is:

What the reason that the swap memory is increasing – because high level of RAM usage or something else?

You dont have high level of ram usage. read this You can check by typing free -h or free -m and look at the line with

-/+ buffers/cache:

The reason for increasing swap usage is because you only have 2GB of ram and if i am not mistaking your swappiness is 60 : read this for swappiness

If you want to swap less memory lower the value but i do not recommend it!

NIZ
  • 131
  • 4