lkml.org 
[lkml]   [2007]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRE: Question about free/used memory on Linux
Date
From
Hi Vaidy,
What do you think is the right way to get the memory usage of a
process, I mean the actual physical memory used ? Basically,
I'm interested in the incremental cost of a process, which
means, I don't want to include the text segments of shared
libraries which would remain even after the process is killed
(since it would be used by other processes).

Is the RSS field of "ps aux" command the right one or use
"pmap" command and look at the "writeable" segments ?

Thanks,
Ravi

-----Original Message-----
From: Vaidyanathan Srinivasan [mailto:svaidy@linux.vnet.ibm.com]
Sent: Sunday, October 21, 2007 10:50 PM
To: Ravinandan Arakali (rarakali)
Cc: Linux Kernel
Subject: Re: Question about free/used memory on Linux


Ravinandan Arakali (rarakali) wrote:
> Hi Vaidy,
> Thanks for clarifying several of my doubts.
>
> To answer your question about my intention, we currently have a system

> with 2 GB RAM and I need to find out the actual used and free memory
> so that we can decide if the same setup(applications, tmpfs etc.) can
> run on another system with lesser memory.
>
> Is it correct to say that the "used" field "free -m" excluding
> buffers/caches would give the correct idea of used memory (I mean does

> it take care of shared memory, shared copies of libraries etc.) ? I
> assume it does not include /dev/shm usage since that's also a tmpfs
> partition ?

Thats correct. The used excluding the buffer caches gives most of the
memory used by the system. You have excludes _all_ file backed memory
including shm.

>
> If so, then I can add the memory used by tmpfs partitions to the above

> and get the total memory used ?
>
> For eg. if my "free -m" appears as below:
> Linux(debug)# free -m
> total used free shared buffers
> cached
> Mem: 2014 984 1030 0 80
> 594
> -/+ buffers/cache: 309 1705
>
> Can I say that 309MB + 350 MB(size of tmpfs partitions including
> /dev/shm)
> is the used memory on my system ?

Two problems with this logic:

1. all of tmpfs may not be really used. You are over committing.
2. You still miss the pages needed to map the program code. They are
file backed too. Though this will be very less amount of memory compared
to data and shared memory.

Let me suggest a metric:

1. Take the used part excluding the buffers (309MB) in your case and add
'Mapped' and 'Dirty' from /proc/meminfo

This may be better than adding tmpfs/shmdev size.

2. Once your system is running will all applications loaded, cleanup the
pagecache (file data cached in memory)

sync
echo 1 > /proc/sys/vm/drop_caches

The first sync will bring down 'Dirty' count and drop_caches will
reclaim all 'not needed' file cache memory.

Now if you use 'free' and take the used count _with_ the buffers and
file cache, this will provide a realistic value. (Actually Free in
/proc/meminfo)

Do not exclude buffers they are _needed_ for optimum system operation.
With the above figure you can probably add 10% or more memory as extra
memory for file cache when the system is operating with full load.

If you want to be sure of these experiments boot you system with less
memory using mem=xxx kernel parameter and run some performance tests to
ensure the degradation is under acceptable limits.

--Vaidy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-11-14 07:17    [W:0.074 / U:3.924 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site