FAQ
Does anyone have a fairly accurate method for determining
how much memory is actually being used on a Linux box?

The linux in question is RedHat Enterprise Server 4.

Before dashing off a reply to use 'ps -F' to get the RSS
column, or using pmap -qx to get the various memory
segment sizes, or using /proc/PID/stats|statsm|status|,
please consider that these methods do not work, as Linux
does not always correctly report the memory in use.

Is there any other method that you have found to
work correctly? I will define 'correctly' here as
within 10% of what the actual memory use is.

--
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist

--
http://www.freelists.org/webpage/oracle-l

Search Discussions

  • Kevin Closson at Oct 2, 2006 at 8:43 pm
    Does anyone have a fairly accurate method for determining
    how much memory is actually being used on a Linux box?

    The linux in question is RedHat Enterprise Server 4.

    ...yes, free(1):

    [root_at_tmr6s14 ~]# free

    total used free shared buffers
    cached
    Mem: 32752464 1904580 30847884 0 65444
    1523444

    -/+ buffers/cache: 315692 32436772
    Swap: 2040244 0 2040244

    ...you rephrased the question after posting to the oaktable,
    phrased this way took a lot less typing to answer :)
  • Jared Still at Oct 2, 2006 at 9:04 pm
    Thanks, though I think you knew what I meant. :)

    To be more precise in what I am asking:

    According to the ps man page:

    rss RSS resident set size, the non-swapped physical
    memory that a task has used (in kiloBytes).

    (alias rssize, rsz).

    What's interesting is that summing RSS for all Oracle processes
    on the server in question (RH ES 4 64 Bit) yield 25 gig of RAM.

    The server has only 12 gig of RAM.

    Here's the ps command:

    ps -fywluoracle | awk '{ mem=mem+$8 } END{ mem=mem*1024; print "bytes: ",
    mem}'

    My question is: Does someone here know what is really being reported by
    RSS?

    Or is it just untrustworthy?

    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist

    Sample output

    [root_at_ordb02 bin]# ps -fywluoracle | head
    S UID PID PPID C PRI NI RSS SZ WCHAN STIME TTY TIME
    CMD
    S oracle 23792 1 0 76 0 17196 135561 - Sep04 ? 00:01:27
    ora_pmon_pr02
    S oracle 23794 1 0 76 0 15340 135266 - Sep04 ? 00:00:14
    ora_psp0_pr02
    S oracle 23796 1 0 76 0 15408 135266 - Sep04 ? 00:00:00
    ora_mman_pr02
    S oracle 23798 1 0 76 0 120164 147379 - Sep04 ? 00:15:59
    ora_dbw0_pr02
    S oracle 23800 1 0 76 0 24016 139159 - Sep04 ? 00:14:57
    ora_lgwr_pr02
    S oracle 23802 1 0 76 0 27228 135923 - Sep04 ? 00:03:47
    ora_ckpt_pr02
    S oracle 23804 1 0 76 0 239228 135937 - Sep04 ? 00:03:41
    ora_smon_pr02

    --
    http://www.freelists.org/webpage/oracle-l
  • Matthew Zito at Oct 2, 2006 at 9:13 pm
    Shared memory shows up in the RSS of each process....so I suppose you
    could do complicated math surrounding subtracting out the SGA for all
    processes that attach therein, and then add it up....


    Matt

    From: oracle-l-bounce_at_freelists.org
    On Behalf Of Jared Still

    Sent: Monday, October 02, 2006 5:04 PM
    To: kevinc_at_polyserve.com
    Cc: Oracle-L Freelists
    Subject: Re: Linux Memory Accounting

    Thanks, though I think you knew what I meant. :)

    To be more precise in what I am asking:
    --------------------------------------

    According to the ps man page:

    rss RSS resident set size, the non-swapped
    physical memory that a task has used (in kiloBytes).
    (alias rssize, rsz).

    What's interesting is that summing RSS for all Oracle processes
    on the server in question (RH ES 4 64 Bit) yield 25 gig of RAM.

    The server has only 12 gig of RAM.

    Here's the ps command:

    ps -fywluoracle | awk '{ mem=mem+$8 } END{ mem=mem*1024; print

    "bytes: ", mem}'


    My question is: Does someone here know what is really being
    reported by RSS?


    Or is it just untrustworthy?


    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist

    Sample output

    [root_at_ordb02 bin]# ps -fywluoracle | head
    S UID PID PPID C PRI NI RSS SZ WCHAN STIME TTY
    TIME CMD
    S oracle 23792 1 0 76 0 17196 135561 - Sep04 ?
    00:01:27 ora_pmon_pr02
    S oracle 23794 1 0 76 0 15340 135266 - Sep04 ?
    00:00:14 ora_psp0_pr02
    S oracle 23796 1 0 76 0 15408 135266 - Sep04 ?
    00:00:00 ora_mman_pr02
    S oracle 23798 1 0 76 0 120164 147379 - Sep04 ?
    00:15:59 ora_dbw0_pr02
    S oracle 23800 1 0 76 0 24016 139159 - Sep04 ?
    00:14:57 ora_lgwr_pr02
    S oracle 23802 1 0 76 0 27228 135923 - Sep04 ?
    00:03:47 ora_ckpt_pr02
    S oracle 23804 1 0 76 0 239228 135937 - Sep04 ?

    00:03:41 ora_smon_pr02





    --
    http://www.freelists.org/webpage/oracle-l
  • Siva Valiveru at Oct 2, 2006 at 8:47 pm
    $cat /proc/meminfo

    -----Original Message-----
    From: oracle-l-bounce_at_freelists.org
    On Behalf Of Kevin Closson
    Sent: Monday, October 02, 2006 1:44 PM
    To: Oracle-L Freelists
    Subject: RE: Linux Memory Accounting



    Does anyone have a fairly accurate method for determining
    how much memory is actually being used on a Linux box?

    The linux in question is RedHat Enterprise Server 4.

    ...yes, free(1):

    [root_at_tmr6s14 ~]# free

    total used free shared buffers
    cached
    Mem: 32752464 1904580 30847884 0 65444
    1523444

    -/+ buffers/cache: 315692 32436772
    Swap: 2040244 0 2040244

    ...you rephrased the question after posting to the oaktable, phrased
    this way took a lot less typing to answer :)

    --
    http://www.freelists.org/webpage/oracle-l

    --
    http://www.freelists.org/webpage/oracle-l
  • Jared Still at Oct 2, 2006 at 9:02 pm
    Thanks, but that cannot be used to determine how much memory Oracle is
    using.

    Please see my previous reply on this.

    Jared
    On 10/2/06, Siva Valiveru wrote:

    $cat /proc/meminfo

    -----Original Message-----
    From: oracle-l-bounce_at_freelists.org
    On Behalf Of Kevin Closson
    Sent: Monday, October 02, 2006 1:44 PM
    To: Oracle-L Freelists
    Subject: RE: Linux Memory Accounting



    Does anyone have a fairly accurate method for determining
    how much memory is actually being used on a Linux box?

    The linux in question is RedHat Enterprise Server 4.

    ...yes, free(1):

    [root_at_tmr6s14 ~]# free
    total used free shared buffers
    cached
    Mem: 32752464 1904580 30847884 0 65444
    1523444
    -/+ buffers/cache: 315692 32436772
    Swap: 2040244 0 2040244



    ...you rephrased the question after posting to the oaktable, phrased
    this way took a lot less typing to answer :)
    --
    http://www.freelists.org/webpage/oracle-l


    --
    http://www.freelists.org/webpage/oracle-l

    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist

    --
    http://www.freelists.org/webpage/oracle-l
  • Jared Still at Oct 2, 2006 at 9:45 pm
    Do you have a script/process that does that?

    I'm not into reinventing the wheel here if I can avoid it.

    Would be sweet if linux actually knew how to properly account for its
    memory.

    Jared
    On 10/2/06, Thomas A. La Porte wrote:

    Isn't the overage related to shared memory?

    I.e. the RSS for any one process includes *all* of the shared
    memory used by that process. And so when four processes share a
    1GB memory segment, the sum of RSS == 4GB, while physical memory
    used is actually only 1GB?

    -- Tom
    On Mon, 2 Oct 2006, Jared Still wrote:

    Thanks, though I think you knew what I meant. :)

    To be more precise in what I am asking:
    --------------------------------------

    According to the ps man page:

    rss RSS resident set size, the non-swapped physical
    memory that a task has used (in kiloBytes).
    (alias rssize, rsz).

    What's interesting is that summing RSS for all Oracle processes
    on the server in question (RH ES 4 64 Bit) yield 25 gig of RAM.

    The server has only 12 gig of RAM.

    Here's the ps command:

    ps -fywluoracle | awk '{ mem=mem+$8 } END{ mem=mem*1024; print "bytes: ",
    mem}'

    My question is: Does someone here know what is really being reported by
    RSS?
    Or is it just untrustworthy?
    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist

    --
    http://www.freelists.org/webpage/oracle-l
  • Hemant K Chitale at Oct 3, 2006 at 3:27 pm
    Try MetaLink note 269426.1

    Hemant
    At 03:47 AM Tuesday, Jared Still wrote:

    Does anyone have a fairly accurate method for determining
    how much memory is actually being used on a Linux box?
    Hemant K Chitale
    http://web.singnet.com.sg/~hkchital
  • Jared Still at Oct 3, 2006 at 9:47 pm
    That note refers to statm|stat|status pmap, etc.

    Those are all inaccurate for real memory accounting.
    On 10/3/06, Hemant K Chitale wrote:


    Try MetaLink note 269426.1

    Hemant
    At 03:47 AM Tuesday, Jared Still wrote:

    Does anyone have a fairly accurate method for determining
    how much memory is actually being used on a Linux box?

    Hemant K Chitale
    http://web.singnet.com.sg/~hkchital

    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist

    --
    http://www.freelists.org/webpage/oracle-l
  • Frits Hoogland at Oct 3, 2006 at 3:52 pm
    jared,
    processing RSS is a wrong way of calculating memory usage.
    It's alrights for private memory/PGA, but oracle uses shared memory, in
    which the SGA resides.
    That memory is not bound to a specific process, rather a linux/unix system
    keeps track of the processes which access them, so current PID and creater
    pid are kept.
    the RSS is calculated of private memory + touched shared memory pages
    this means accumulating all RSS amount for all database processes, the
    chance you calculate memory twice is fairly big, and gets higher once the
    instance is longer alive (the background processes are able to touch more
    shared memory)

    this means it's impossible to calculate database memory usage in a simple
    way by examining the processes at OS level.

    it's also worth to note that shared memory usage display is turned off by
    default in linux (at least in the recent 2.4 kernels and the RHEL3 and
    4 2.6kernels) in /proc/meminfo. A way to get linux display shared
    memory pages is
    (of course) ipcs -ma, and also with (as root):
    echo m > /proc/sysrq-trigger; dmesg | grep shared

    so I'd go with kevin's recommandation to use some tool to look at global OS
    level to see memory usage. besides the omitted shared memory, it's accurate.

    frits
    On 10/2/06, Jared Still wrote:


    Does anyone have a fairly accurate method for determining
    how much memory is actually being used on a Linux box?

    The linux in question is RedHat Enterprise Server 4.

    Before dashing off a reply to use 'ps -F' to get the RSS
    column, or using pmap -qx to get the various memory
    segment sizes, or using /proc/PID/stats|statsm|status|,
    please consider that these methods do not work, as Linux
    does not always correctly report the memory in use.

    Is there any other method that you have found to
    work correctly? I will define 'correctly' here as
    within 10% of what the actual memory use is.


    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist
    --
    http://www.freelists.org/webpage/oracle-l
  • Jared Still at Oct 3, 2006 at 9:57 pm
    Hi Frits,

    Comments inline:
    On 10/3/06, Frits Hoogland wrote:

    this means it's impossible to calculate database memory usage in a simple
    way by examining the processes at OS level.
    Yes, I've discovered that.

    so I'd go with kevin's recommandation to use some tool to look at global OS
    level to see memory usage. besides the omitted shared memory, it's accurate.
    I've cobbled together a script to scan the /proc//maps files for
    a process owner, and add up the memory, hopefully with a minimum
    of double counting.

    The results for running it on 2 servers are approximately what I
    would expect to see. This includes shared memory.

    http://jaredstill.com/downloads/proc_mem_used.tgz

    Comments, suggestions and/or improvments are welcomed.

    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist

    --
    http://www.freelists.org/webpage/oracle-l
  • Jesse, Rich at Oct 4, 2006 at 5:05 pm
    Hey Jared,


    I'll have to check this out (may help with new ERP go-live), but you
    seem to imply that this accounting issue is only an issue on Linux.
    This isn't the case for HP-UX, Solaris, and AIX?


    I can't say I've treated it any other way, although I can only recall
    needing to look at this info once before...


    Rich

    From: oracle-l-bounce_at_freelists.org
    On Behalf Of Jared Still
    Sent: Tuesday, October 03, 2006 4:58 PM
    To: Frits Hoogland
    Cc: Oracle-L Freelists
    Subject: Re: Linux Memory Accounting

    Hi Frits,

    Comments inline:

    On 10/3/06, Frits Hoogland wrote:

    this means it's impossible to calculate database memory usage in
    a simple way by examining the processes at OS level.

    Yes, I've discovered that.

    so I'd go with kevin's recommandation to use some tool to look
    at global OS level to see memory usage. besides the omitted shared
    memory, it's accurate.



    I've cobbled together a script to scan the /proc//maps files for
    a process owner, and add up the memory, hopefully with a minimum
    of double counting.

    The results for running it on 2 servers are approximately what I
    would expect to see. This includes shared memory.

    http://jaredstill.com/downloads/proc_mem_used.tgz

    Comments, suggestions and/or improvments are welcomed.

    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist

    --
    http://www.freelists.org/webpage/oracle-l
  • Christo Kutrovsky at Oct 4, 2006 at 5:18 pm
    Jared,

    I am working on a presentation that will answer these exact questions.
    I have the abstract here:

    http://www.pythian.com/blogs/255/the-answer-to-free-memory-swap-oracle-and-everything

    --
    Christo Kutrovsky
    Senior Database/System Administrator
    The Pythian Group - www.pythian.com
    I blog at http://www.pythian.com/blogs/
    On 10/3/06, Jared Still wrote:
    Hi Frits,

    Comments inline:
    On 10/3/06, Frits Hoogland wrote:
    this means it's impossible to calculate database memory usage in a simple
    way by examining the processes at OS level.

    Yes, I've discovered that.
    so I'd go with kevin's recommandation to use some tool to look at global
    OS level to see memory usage. besides the omitted shared memory, it's
    accurate.
    I've cobbled together a script to scan the /proc//maps files for
    a process owner, and add up the memory, hopefully with a minimum
    of double counting.

    The results for running it on 2 servers are approximately what I
    would expect to see. This includes shared memory.

    http://jaredstill.com/downloads/proc_mem_used.tgz

    Comments, suggestions and/or improvments are welcomed.


    --
    Jared Still
    Certifiable Oracle DBA and Part Time Perl Evangelist
    --
    Christo Kutrovsky
    Senior Database/System Administrator
    The Pythian Group - www.pythian.com
    I blog at http://www.pythian.com/blogs/
    --
    http://www.freelists.org/webpage/oracle-l

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouporacle-l @
categoriesoracle
postedOct 2, '06 at 7:47p
activeOct 4, '06 at 5:18p
posts13
users8
websiteoracle.com

People

Translate

site design / logo © 2022 Grokbase