Forum Stats

  • 3,838,771 Users
  • 2,262,398 Discussions
  • 7,900,755 Comments

Discussions

Used memory or percentage by oracle user (OS command)

Yossi Nixon
Yossi Nixon Member Posts: 74 Bronze Badge
edited Jun 27, 2020 1:06PM in Oracle Linux

Hi,

I would like to check:

1. How much total memory is used by all processes

2. How much memory we have total in the OS

3. How much memory specific Oracle instance is using

So I will be able to calculate:

A. percentage (usage) of Oracle instance

B. percentage (usage) of all system processes

All the calculation should be done from the OS only (not SQL)

Remember: Oracle is using also shared memory and huge pages.

Testing if we got the right formula:

I. Oracle instance usage < Total usage

II. Summary of all Oracle instances usage <= Total usage

For questions 1 and 2, I am using the command free

For question 3

I tried to use the command ps to summarize the memory (tried them all rss,vsz ...)

Then I realized we have shared memory, so I need to use unique memory addresses, used the command map (https://gist.github.com/lucaslellis/7506394 )

and then I found the great utility smem .

On Centos, the numbers work fine.

smem_fdborcl19node1.png

On Oracle Linux, I got Oracle instance usage > Total usage (and above 100%)

smem_dg11gn1.png

I assume something on this host is configured differently (maybe oracle massed with the kernel different than other distributions)

Any idea what is the reason?

Any other way to calculate it?

Tagged:
Billy Verreynne

Answers

  • Dude!
    Dude! Member Posts: 22,830 Black Diamond
    edited Jun 25, 2020 1:50PM

    You can't just compare the numbers between different systems. Asking why one system shows 72 % and another 198 % I don't know. I suggest to check the RSS sizes using ps or top and compare it with your other system to see if it adds up what SMEM is reporting.

    RSS, from what I understand won't be useful for your purpose. SMEM RSS includes the total all of the shared libraries that the process use, even though a shared library is only loaded into memory once regardless of how many processes use it. Hence the more process you have sharing the same library, the higher the total sum of RSS, which can be higher than the total memory used.

    The PSS column might be more interesting for your purpose.

  • Yossi Nixon
    Yossi Nixon Member Posts: 74 Bronze Badge
    edited Jun 25, 2020 11:38PM

    Is there another way to monitor PSS with standard command (no need to explicit install) ?

  • Yossi Nixon
    Yossi Nixon Member Posts: 74 Bronze Badge
    edited Jun 26, 2020 1:45AM

    ok, I found an explanation for PSS in https://www.golinuxcloud.com/check-memory-usage-per-process-linux/

    So I wrote a mall script

    pids=$(ps aux |grep $ORACLE_SID |awk '{print $2}')for pid in $pids; do    if [ -r /proc/$pid/smaps ]; then        pidpss=$(cat /proc/$pid/smaps 2> /dev/null | grep -i pss |  awk '{Total+=$2} END {print Total}')        if [ ! -z "${pidpss##*[!0-9]*}" ]; then            totalpss=$(expr $totalpss + $pidpss)        fi    fidoneecho $totalpss

    Thanks

  • Dude!
    Dude! Member Posts: 22,830 Black Diamond
    edited Jun 26, 2020 12:04PM

    IPCS is the standard tool to query SYSV memory and other resources.

    Have you seen the following:

    https://access.redhat.com/solutions/320303

    Let's say you acquire all the needed info, what are you planing to do with the result?

  • Tommy.Reynolds-Oracle
    Tommy.Reynolds-Oracle Member Posts: 1,754 Employee
    edited Jun 27, 2020 11:30AM
    1. How much total memory is used by all processes
    2. How much memory we have total in the OS
    3. How much memory specific Oracle instance is using

    There is no One True Answer(tm) to these questions.  Indeed, calculating the answer twice in a row will give different results because of all the memory management layers between the tool and the hardware.  The kernel tries very hard to constantly adjust how it allocates system resources to adapt to the current work load: how much memory is used for I/O buffers; how much memory is used for program text; how much memory is used for program data; does a memory VM page need to be evicted from memory to acquire space for a more-important use.  Here be dragons.

    A better approach is to deal with specific performance issues; who cares how much physical memory is being used as long as it is enough?  So please recast your questions to deal with a performance observation such as "my server is running slowly" or "can I add another RDBMS instance."  Performance questions describe behavior over time but "how much" questions are about an instantaneous snapshot in time.

    So, what problem do you want to solve?

    Billy Verreynne
  • Dude!
    Dude! Member Posts: 22,830 Black Diamond
    edited Jun 27, 2020 1:06PM

    Also, if I may add... Any unused memory is wasted memory.

    https://www.linuxatemyram.com/

    Oracle database uses allocated and free memory for caching likewise to improve performance. The Linux kernel can tell how much memory is used for kernel buffering, but it cannot determine Oracle memory usage. Hence you will need to query Oracle database via SQL to find out.