[plug] Linux memory question

Campbell, David (Ex AS17) david.j.campbell at honeywell.com
Wed Feb 28 16:52:12 WST 2001


> Anthony J. Breeds-Taurima wrote:
> Hello All,
> I have a friend that works in porting Unix Apps from one OS to another.
>
> He asked me several pointed questions about linux memory accounting.
> I don't know the answers myself.  Now "Use the source luke" is not an
> approriate answer, and niether is "email the maintainer."
> 
> Do you guys know the answers to:
> 1) What is cache (physical memory), as reported by free, and what does it
> contain ?

Disk cache, eg: DLLs and executables, read only memory, first to get trashed
in a memory crisis.

> 2) What is buffers (physical memory), as reported by free, and what does
it
> contain ?

User program IO buffer space, eg: stdout, sockets, anything where data is
entering or leaving the program.

> 3) Is shared memory a combination of used, buffers & cache ?
> or used & buffers?  or used & cache ?

I think shared memory comes under the classification of "used", basically
it is locked in there with program data. Last to leave the house in a memory
crunch (unless all the programs using the shared memory page have been
paged out).

BTW: What type of shared memory? Pure shared memory or memory mapped file?
A memory mapped file could be split between "used", "buffers" depending on
how Linux does shared memory (device drivers are my area).

> 4) Does Linux have a parameter like other UNIX's such as DESFREE, used by
Solaris?
> In Solaris, FREEMEM is compared to DESFREE, if it is lower then it will
start
> desperation swapping to free up memory to above this level.
> If Linux doesn't have this parameter what technique does it use to free
memory ?

Not that I have seen. From memory swapping occurs on a "as need" basis.

OK, so your daemons may have a little extra time forking but Linux
uses a copy-on-write page method so the actual page count
requirements are lower. I would suggest your friend try some
threaded programming rather than forking (unless there is a
real need such as setuid(), BTW is it "C", "C++" or FORTRAN? ).

I don't have the kernel source handy today to confirm
the above (or to quote examples)

David Campbell



More information about the plug mailing list