6 Replies Latest reply on Jun 27, 2020 5:06 PM by Dude!

    Used memory or percentage by oracle user (OS command)

    Yossi Nixon

      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?

        • 1. Re: Used memory or percentage by oracle user (OS command)
          Dude!

          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.

          • 2. Re: Used memory or percentage by oracle user (OS command)
            Yossi Nixon

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

            • 3. Re: Used memory or percentage by oracle user (OS command)
              Yossi Nixon

              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

                  fi

              done

              echo $totalpss

              Thanks

              • 4. Re: Used memory or percentage by oracle user (OS command)
                Dude!

                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?

                • 5. Re: Used memory or percentage by oracle user (OS command)
                  Tommy.Reynolds-Oracle
                  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?

                  • 6. Re: Used memory or percentage by oracle user (OS command)
                    Dude!

                    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.