Re: Memory management



Stephane Dupille <stephane@xxxxxxxxxxx> wrote:
Peter Jeremy <peterjeremy@xxxxxxxxxxxxxxxx> écrit :
As time passing by, the memory fills up. When the machine starts,
memory is occupied to 30 %, and after two or three weeks memory is
occupied to 100 % and it begins to use swap.
How are you monitoring memory usage?

Using top, mainly. And ps, swapinfo, vmstat...

Do you mean 'swap' or 'page'?

swap.

Note that it is normal that processes get swapped out if
they haven't been in the run queue for a very long time
and "free" memory has reached near zero (which is also
normal). That's a feature, because it improves efficiency
in most situations, because more RAM is available to
processes which really need it.

For example, if you use X11 and don't log into syscons'
virtual terminals (/dev/vty*), you will notice that the
getty(8) processes will be swapped out after some time
when there is not many "free" memory left:

PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
382 root 3 0 996K 0K ttyin 0:00 0.00% 0.00% <getty>
383 root 3 0 996K 0K ttyin 0:00 0.00% 0.00% <getty>
384 root 3 0 996K 0K ttyin 0:00 0.00% 0.00% <getty>
385 root 3 0 996K 0K ttyin 0:00 0.00% 0.00% <getty>
386 root 3 0 996K 0K ttyin 0:00 0.00% 0.00% <getty>

If you want to check whether there's a _real_ shortage of
RAM (or a memory leak somewhere), a good way is to watch
the "po" and "sr" columns in the output of "vmstat 5":

procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr ad0 da0 in sy cs us sy id
1 0 0 39960 44944 62 0 0 0 61 3 0 0 157 6 36 2 1 97
0 0 0 39960 44944 2 0 0 0 0 0 0 0 1132 19 8 0 0 100
0 0 0 39960 44944 1 0 0 0 0 0 0 1 1132 19 8 0 0 100
0 0 0 34300 44944 1 0 0 0 0 0 0 0 1132 23 9 0 0 100

The "po" (page-out) column indicates paging activity, i.e.
data is moved to the swap. The "sr" (scan-rate) column
measures the speed at which inactive pages are scanned for
becomeing cache or "free" pages; this number is a good
measure of the "pressure" on the VM system.

If both numbers are almost always near zero, you don't
have to worry at all. If the numbers are constantly
high, you either have a leak somewhere that you need to
discover, or you need to add more RAM to your machine.

Best regards
Oliver

--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
_______________________________________________
freebsd-stable@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: OT (slightly) swap limits
    ... influence your decision on how much swap was enough. ... processes due to lack of memory. ... I've run machines with 1Gig or more RAM with NO SWAP. ... Linux possible when before on Unix it wasn't? ...
    (Debian-User)
  • Re: How to set up a Linux machine that occupies the minimum memory footprint ?
    ... >> memory and hence causes the kernel to 'thrash' thus slowing down the ... 4GB physical RAM + 4GB swap area) the application will think that it can ... You've said in another message that your app is ...
    (comp.os.linux.setup)
  • Re: How to set up a Linux machine that occupies the minimum memory footprint ?
    ... >> memory and hence causes the kernel to 'thrash' thus slowing down the ... 4GB physical RAM + 4GB swap area) the application will think that it can ... You've said in another message that your app is ...
    (comp.os.linux.misc)
  • Re: fedora-list Digest, Vol 10, Issue 167
    ... Well, I have two 433 MHz Celerons and 288 MB RAM, and no performance ... > The memory usage is always around 400MB. ... I'd like to introduce you to the vmstat command. ... > I know that SWAP should be double the Physical RAM but I don't have ...
    (Fedora)
  • Re: FreeBSD data size tuning
    ... It seems there is a memory issue in 4.9 where they adapted 5.x things ... RAM and using 2500MB of swap on ide disk, ... With 1GB of RAM you should be able to run squid without any ...
    (freebsd-performance)