Swapless system: processes killed in favor of disk cache?

Martin Hedenfalk martinh at servicefactory.se
Tue Sep 13 00:16:06 PDT 2005


Hello list,

We're running a swapless FreeBSD 4.10 system. Although we do have a 
disk in this particular system, it is currently not used as swap.

The problem we're experiencing is that when storing a large file on the 
disk, a lot of memory is used (same as the size of the file). This 
leads to random processes being killed with an "out of swap space" 
message.

Running top when dd'ing 30 MiB from /dev/zero to a file on disk shows 
free memory dropping 30 MiB, and Inact and Wired combined increasing 
for the same amount.

I was able to change this behaviour by opening the file with the 
O_DIRECT flag. But this only fixes one problem in one particular 
application, and I'd like to understand what is actually going on.

So, is all this memory used for disk cache? If so, why is it not 
invalidated when a process wants to allocate memory?

Are there any sysctl's that controls this behaviour? I've tried setting 
vm.swap_enabled=0,  vm.defer_swapspace_pageouts=1, and 
vm.disable_swapspace_pageouts=1.

Thanks in advance
Martin Hedenfalk



More information about the freebsd-questions mailing list