Date: Wed, 26 Jul 2006 15:17:09 +0200 (CEST) From: Oliver Fromme <olli@lurza.secnetix.de> To: freebsd-stable@FreeBSD.ORG Subject: Re: Memory management Message-ID: <200607261317.k6QDH9rH091312@lurza.secnetix.de> In-Reply-To: <ygemzawa8af.fsf@nospam.fr.eu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Stephane Dupille <stephane@dupille.org> wrote: > Peter Jeremy <peterjeremy@optushome.com.au> é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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607261317.k6QDH9rH091312>