[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Question about memory use in Linux



On Saturday 03 November 2001 18:52, David P James wrote:
> My Debian Woody box has 128Mb of RAM, and a 128Mb swap partition...
> ...I understand that linux uses essentially as much RAM as it can
> because it is there. Now, I opened up that colossal memory hog, WP9 for
> linux. The RAM usage shot up to 99% (about 7Mb more) BUT the swap usage
> only went up by .75Mb... ...Then, shutting down all 4 apps of WPO had an
> interesting effect - swap usage slipped by 3Mb but RAM usage went below
> 100Mb, or 80%.

This is easy, it's called a file cache.. ;) you see linux keeps a copy of
files you've opened in memory to speed up secondary access of file. If you
open a new file or exicute a binary, if it's got a load of file cache it'll
purge the older files from the cache to make way for the 'new' binary. When I
open a 200Mb file it'll page a little bit into swap but most ram will be
reclamed from the file cache (given that I've normaly got a >1Gb file cache).

> A somewhat related question is there any point in having 128Mb of swap? If
> I had had 64 instead would it still carry on as it does or would it have
> scaled back the system's swap usage in some proportion?

I duno, I tend to run 2-4Gb swap partitions (mainly cause I have older SCSI
HD's in the 2-4Gb area) and typicaly I've got 100Mb of swap (currently I've
got 91Mb swap, with a 1.3Gb file cache & 160Mb used).

> Likewise, would adding another swap partition increase the amount of swap
> being used or just spread it around some more?

Adding a 2nd swap file on a disk seems counter productive as you've not got 2
stores and unless the swap priorty is the same will jump between then making
things slower. I don't understand swap priortys but to say you can tell linux
to swap to 1 partition in prefrence to another.

Multi-swap partitions on seperate disks can make swap faster but on IDE disks
it seems to be more of a hinderence than a benafit, SCSI seems to benafit
from havin' swap distrubuted over serveral drives.

Ani



Reply to: