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

Re: Question about memory use in Linux



"Aniartia (by way of Aniartia )" wrote:
> 
> 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).

  some programs (gkrellm, IIRC xosview etc.) let you see how the memory
is used so you can see whether it's actually used by programs or by
cache. the memory used by file cache is almost as good as free memory as
far as the programs are concerned... (it would be used in case programs
need mor memory)

> > 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).

  imo it's good to have a little bit more cache than it's reasonable -
it's better to have your system slowed down than for programs to be
killed because of some memory problem. Of course, if you see swap to be
used too often (the disk is busy while you're switching programs etc.,
you can see it in gkrellm, xosview or other memory monitor program) you
clearly need more ram.

  cache might be also used in cases when it's not strictly neccessary -
e.g. in your case - when something is swapped out it is not 'unswapped'
until it's needed, the extra free memory is used as filesystem cache...

	erik



Reply to: