Re: Memory management




On Wed, 26 Jul 2006, Stephane Dupille wrote:

I have a computer running FreeBSD 6.1.

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.

It is "inactive" pages that fills up the memory.

I tried to restart every process, but memory usage does not decrease. Only a reboot can fix that. And I'm not able to see which process leaks.

I was not able to find a correct definition of what "inactive" memory is. First, I would like to know what are these kind of pages : wired, active, inactive, cache and free.

Is that normal that inactive memory usage grows ? What should I do ?

Do you have any tools to monitor memory usage of processes ?

You can find an article discussing some of the FreeBSD VM system design here:

http://www.freebsd.org/doc/en_US.ISO8859-1/articles/vm-design/article.html

This document is gradually aging, and doesn't cover certain elements of the design, including some recent optimizations, SMP behavior, etc, but still makes quite a good read.

It could be that you have applications leaking memory, but it's more likely that the VM system is simply being efficient. Free memory is, in effect, wasted memory, since it's not being used. FreeBSD will agressively cache file system data, and either drop or page out unused pages (depending on whether they are dirty) in order to maximize the amount of memory available for actively used data. This means it will swap out dirty pages allocated by a process if the process isn't using them, rather than keep them in memory preventing that memory from being used by processes that need it. The result is that at any given moment, an active system should have almost no free memory, and instead should be providing as much memory as possible to active pages, and the largest possible file system cache. This may seem counter-intuitive compared to some other systems where a premium is placed on free pages as representing the resources available to run additional applications. We consider memory floating around "unused" to be a waste of memory that could be used to improve system performance.

"systat -vmstat 1" is a good tool to monitor the VM system, as it will let you monitor memory use, in particular, the vnode and swap paging rates. You can use ps(1) with various parameters to inspect process memory use. A popular combination is "aux", which views all processes and displays, among other things, their virtual and resident sizes. The resident size is the figure you want to look at, as it represents the number of pages actually in memory, rather than pages that could be paged in.

Robert N M Watson
Computer Laboratory
University of Cambridge
_______________________________________________
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: RFT: updatedb "morning after" problem [was: Re: -mm merge plans for 2.6.23]
    ... memory freed it so there is free memory that could be filled with data ... in some other situations swap prefetch cannot help becouse useless data is getting cached at the expense of useful data. ... the design is to use CPU and I/O capacity that's otherwise idle to fill free memory with data from swap. ... Upon completion, it actually frees enough memory that swap-prefetch _could_ help on some boxes, while the real issue is that they should first and foremost dump GNU locate. ...
    (Linux-Kernel)
  • Re: Solaris 2.6 high pages scans
    ... > I can see the the amount of free memory rarely dips below 230MB and the ... list and is seen by the page scanner as in use. ...
    (comp.unix.solaris)
  • Re: Memory not freed when unloading forms
    ... > What's not fine is the severe problem we are experiencing: ... > program to monitor the global amount of free memory. ... > in our application, free memory decreased a little, let's say 7%. ... > correctly after unloading a form. ...
    (microsoft.public.vb.general.discussion)
  • Re: [PATCH 0/8][for -mm] mem_notify v6
    ... > Here is the start and end of the output from the test program. ... > has to free memory gets smaller and smaller. ... notification reaction opportunity, ...
    (Linux-Kernel)
  • Re: Computer Running very Slow
    ... also the memory is 256MB and the Bus is 133 Megahertz. ... it's very likely true that there's almost no free memory. ... you should not have *any* available RAM. ... the most common cause for performance issues is malware infestation. ...
    (microsoft.public.windowsxp.help_and_support)