System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Percentage of total memory utilization is shown above 100%.

SOLVED
Go to solution
senthil_kumar_1
Super Advisor

Percentage of total memory utilization is shown above 100%.

Hi All,

In some of linux servers, The percentage of total mem utilization is above 100.

pmem is showing percentage value of rss.
rss is the size of physical memory that a process is using.

Ex:

server 1:

[root@emdlagas1109 ~]# ps -eo user,pid,pmem,comm | awk '{x += $3} END {print x}'
34.2


server 2:

-bash-3.00# ps -eo user,pid,pmem,size,comm | awk '{x += $3} END {print x}'
181.9

in second one it showing as 181.9%, how it is possible.


Pls explain me the purpose of pmem.
13 REPLIES
James R. Ferguson
Acclaimed Contributor
Solution

Re: Percentage of total memory utilization is shown above 100%.

Hi Senthil:

The problem lies in accounting for shared code and data. That is, if two processes use a shared library and/or use common shared memory segments for interprocess communication, the simple sum of the memory requirements for the two processes will be larger than their real contribution.

If this is something more than an academic question, what are you trying to solve?

Regards!

...JRF...
senthil_kumar_1
Super Advisor

Re: Percentage of total memory utilization is shown above 100%.

Hi James,

How can i find the exact percentage of total memory in Linux servers.


James R. Ferguson
Acclaimed Contributor

Re: Percentage of total memory utilization is shown above 100%.

Hi (again):

> How can i find the exact percentage of total memory in Linux servers.

First, why would you care?

Second, without a tool and a rule to measure and apportion memory used by more than one process to only one process (as I first wrote) you have no chance to define "exact percentage".

Third, what would you do if you did have an exact measurement?

Regards!

...JRF...





emha_1
Valued Contributor

Re: Percentage of total memory utilization is shown above 100%.

hi senthil,

question is as well, what in your meaning is percentage of memory usage...

all the memory not used by user processes is automaticaly acquired by kernel for buffers and caches, so the usage is still reaching almost 100%


emha.
senthil_kumar_1
Super Advisor

Re: Percentage of total memory utilization is shown above 100%.

Hi James,

We have to tell the percentage of total memory utilization to out project manager at regular intervals.

so that i am asking "how to find the percentage of total memory utilization".
Steven E. Protter
Exalted Contributor

Re: Percentage of total memory utilization is shown above 100%.

Shalom,

Change the basis of the analysis.

Memory in this context is being shown as physical memory.

Of course you can utilize more than 100% of it because you save swap.

Memory in the HP-UX world is defined as physical memory plus swap.

You need to get the swap size some how and calculate memory use based on real memory capacity which is swap plus physical ram.

Or you can decide that you are utilizing more than 100% of RAM. That is quite possible.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Percentage of total memory utilization is shown above 100%.

Hi (again) Senthil:

> so that i am asking "how to find the percentage of total memory utilization".

You could use 'free()' and compute the ratio of the total memory to the used memory:

# free|awk '/^Mem/ {printf "%4.1f\n",$3/$2*100}'

For example, I had:

# free
total used free shared buffers cached
Mem: 513692 484308 29384 0 33052 308588
-/+ buffers/cache: 142668 371024
Swap: 765944 0 765944

...so:

# free|awk '/^Mem/ {printf "%4.1f\n",$3/$2*100}'

94.4

Regards!

...JRF...

Steven E. Protter
Exalted Contributor

Re: Percentage of total memory utilization is shown above 100%.

Shalom,

I have tested both of JRF's commands on CentOS 5.2

Works great.

One problem with the concept.

By default RHEL assigns most spare memory to the buffer cache.

You will find on systems that are not busy memory utilization is nearly always between 90% and 99%.

Is the buffer pool really used memory?

I say no, because the instant a process wants memory, its pulled out of the pool.

You will probably using JRF's excellent code see a flat line on memory use.

Mem: 329728 324512 5216 0 3624 163188
-/+ buffers/cache: 157700 172028
Swap: 1048568 216 1048352

This is output of free from my system. Buffer cache in Linux is like the buffer pool in HP-UX. Except there is virtually no cost in moving memory in and out of it.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
emha_1
Valued Contributor

Re: Percentage of total memory utilization is shown above 100%.

hi,

slight modification of James' formula to get usage just of user processes

free|awk '/^Mem/ {printf "%4.1f\n",($2-$4-$6-$7)/$2*100}'


emha.
Ramon Ar
Occasional Visitor

Re: Percentage of total memory utilization is shown above 100%.

hi, my english is not good, but i´m gonna try..

in linux, Kernell uses all available physical memory cache to maximize the use of RAM, and so expedite the process. In this case you always see 90 or 99% of RAM used



total used free buffers cached

Mem: 16055 4264 11790 15 3027
-/+ b/cache 1221 14833
Swap: 8189 0 8189

as you can see, the amount of free memory and buffer cache is equal to the free virtual memory, if you make a drop_caches in RH or CentOS, you can watch free virtual memory to continue with the same value, in this case 14 833

free -m|awk '{print $3}'|tail -2|head -1 this is de used memory
Steven E. Protter
Exalted Contributor

Re: Percentage of total memory utilization is shown above 100%.

Shalom,

Memory use can be over 100%, depending on the definition of memory.

If you define memory as RAM, and you have programs of services running in excess of that total, inactive processes will be swapped to disk. Memory use will exceed RAM.

If you define memory as ram plus swap, than it is not possible to exceed 100% memory utilization.

I believe the statement on server 2 is a situation defined above, where memory is being calculated based on physical memory, not total capacity.

What does vmstat show on server 2?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ramon Ar
Occasional Visitor

Re: Percentage of total memory utilization is shown above 100%.

something like that, if we take just as RAM memory, not swap, ie, the idea is to know what the amount of RAM actually used, I think that if we define it that way, the amount of cache + buffer + Free RAM, we could determine an approximate amount of actual free RAM
Balasubramanian, Raja
Occasional Visitor

Re: Percentage of total memory utilization is shown above 100%.

HI Senthil,
I understand your requirement, in a simple manner the solution to your query would be to use free -m
For eg:
$ free -m
total used free shared buffers cached
Mem: 32186 18596 13590 0 828 13587
-/+ buffers/cache: 4180 28006
Swap: 16386 0 16386

From the above o/p the amount of memory actually in use is 4180( free command takes care of calculating the buffers and cache). From this, you can arrive at the percentage usage of memory on your linux server ( In this case would be ~13% used)

Thanks,
RB