On 15 December 2006 13:53, Redouane Boumghar wrote: > Hello all, > > Grant wrote: > > Also, I've noticed in top that when my server's 2GB of memory is > > filled, it uses a small amount of swap (~24k) before it frees some up. > > The "Swap: 24k" then remains. Is that normal? > > Yes I have also notice that after a heavy ram use I get this tiny > space used on my swap. And it remains even after my ram has been half > freed. My box has 1GB of ram and the small amount I sometime get on swap is > 164KB and it can stay like that for 2 weeks, until i reboot. > But I assume rebooting is not a great solution for a server :=) > > Writing to disk is too expensive as Pablo Antonio suggested, so once swap > has been used it won't be cleaned until next use, but how to be sure > it is cleaned at next use ?
That is *not* the reason. Your memory is organised in pages. How much memory a page is, 4KB, 8Kb,..., depends on your memory model and the architecture of your box. Let's assume your systems needs more memory than you have ram installed. So your memory manager searches for pages that haven't been used for a while. Let's assume further that you are running cupsd but haven't printed after booting yet. So it's highly likely that those memory pages occupied by cupsd are swapped out (or actually paged out because linux doesn't do swapping but paging). After a while, your memory usage decreases. Why would cupsd be paged in again unless you start printing? Since cupsd isn't used it stays where it is - in your swap partition. I used cupsd here just as an example. It's the same for many other daemons that are there to provide a service. If you don't use that service the daemon is a very good candidate for being paged out. It isn't a candidate for being paged in again at all as long as you don't use the service. Other good candidates are code parts in applications that are executed exactly once, at start time. Say, you keep your browser open all the time. The initialisation code has been executed when you open the browser first, never thereafter. So it's a very good candidate for being paged out if it fills at least one memory page. It will never be paged in again because it isn't used any more. When you close your browser that code isn't paged in either but simply deleted from swap space. So once your system has started to use swap space, some memory pages will always stay in your swap space because things are paged in again only if they are used. Uwe -- Mark Twain: I rather decline two drinks than a German adjective. http://www.SysEx.com.na -- gentoo-user@gentoo.org mailing list