I am puzzled by the way Linux releases memory, please explain.

I am puzzled by the way Linux releases memory, please explain.

Post by Stephen Cha » Wed, 04 Feb 1998 04:00:00



When I look at the output of "free" in an untax Linux system it typically
resembles the following:

                    total       used       free         shared      buffers
   cached
Mem:         63104      17592      45512      20240       1060       9000
-/+ buffers/cache:       7532      55572
Swap:        68540          0      68540

What puzzles me is when I loaded a few programs, Netscape, Emacs, etc,
and then later exit from each of these programs. My output from "free" is
not anyway close to the original untax state. In fact, under the "used"
column, it sometimes shows +50M when I really don't have any applications
running at all! What exactly is going on? Can someone explain to me the
output of free? Should the numbers add up? Is Linux caching something?
Just how does Linux calculate when to release or cache memory?

Thanks
Stephen

 
 
 

I am puzzled by the way Linux releases memory, please explain.

Post by Mark Ha » Wed, 04 Feb 1998 04:00:00


this should be a FAQ: Linux is good at keeping most of your memory in use.
after all, unused/free memory is _wasted_ memory.  in particular, Linux
will use lots of otherwise-wasted memory to cache disk files.  since this
cache is mostly of 'clean' pages, it can be scavenged (easily, without IO)
when/if some process really needs the space.

 
 
 

I am puzzled by the way Linux releases memory, please explain.

Post by gippa » Wed, 04 Feb 1998 04:00:00



> Is Linux caching something?
> Just how does Linux calculate when to release or cache memory?

It's pretty simple.  When something else wants it, it releases it.
 
 
 

I am puzzled by the way Linux releases memory, please explain.

Post by Eric Lee Gre » Wed, 04 Feb 1998 04:00:00



Quote:>When I look at the output of "free" in an untax Linux system it typically
>resembles the following:
>output of free? Should the numbers add up? Is Linux caching something?
>Just how does Linux calculate when to release or cache memory?

Any unused memory is used for the cache, up to a certain point (see
/usr/src/linux/Documentation/memory-tuning for how to set the various
points). When a program starts up and needs memory, it requests it from the
system. The system then flushes some cache and possibly pages out some
program memory, using a derivative of LRU (least-recently-used) to make room
for the new request.

So, once you've started your system and run it for a while, you should never
see much free memory. If it's free, it's not being used for disk cache, and
if it's not being used for disk cache, your system runs slower.

--

Systems Specialist                    Educational Administration Solutions
   You might be a redneck if you put on insect repellant prior to a date.

 
 
 

I am puzzled by the way Linux releases memory, please explain.

Post by David F » Wed, 04 Feb 1998 04:00:00



> When I look at the output of "free" in an untax Linux system it typically
> resembles the following:

>                     total       used       free         shared      buffers
>    cached
> Mem:         63104      17592      45512      20240       1060       9000
> -/+ buffers/cache:       7532      55572
> Swap:        68540          0      68540

> What puzzles me is when I loaded a few programs, Netscape, Emacs, etc,
> and then later exit from each of these programs. My output from "free" is
> not anyway close to the original untax state. In fact, under the "used"
> column, it sometimes shows +50M when I really don't have any applications
> running at all! What exactly is going on? Can someone explain to me the
> output of free? Should the numbers add up? Is Linux caching something?
> Just how does Linux calculate when to release or cache memory?

I will add another reply to the two already here.  When a program
exits, lets say Netscape, the parts of the executable file that were
paged into memory are left there, in case they are needed again -- you
might start another netscape job.  As time goes by and other memory
requests are made, these pages can be reallocated instantly, they are
just copies of parts of the binary, so they don't need to be written
out to disk.  So the pages never become free again, they are just
marked as available.
--
David Fox          http://www.cat.nyu.edu/fox            xoF divaD

 
 
 

I am puzzled by the way Linux releases memory, please explain.

Post by Miquel van Smoorenbu » Thu, 05 Feb 1998 04:00:00




>When I look at the output of "free" in an untax Linux system it typically
>resembles the following:

>             total       used       free      shared      buffers    cached
>Mem:         63104      17592      45512      20240       1060       9000
>-/+ buffers/cache:       7532      55572
>Swap:        68540          0      68540

You should concentrate on the 2nd column (-/+) and read the "free"
value there. That is what _really_ is available.

Mike.
--
 Miquel van Smoorenburg |  The dyslexic, agnostic, insomniac lay in his bed

 
 
 

I am puzzled by the way Linux releases memory, please explain.

Post by Michael Hirsc » Thu, 05 Feb 1998 04:00:00



> this should be a FAQ: Linux is good at keeping most of your memory in use.
> after all, unused/free memory is _wasted_ memory.  in particular, Linux
> will use lots of otherwise-wasted memory to cache disk files.  since this
> cache is mostly of 'clean' pages, it can be scavenged (easily, without IO)
> when/if some process really needs the space.

Yes, this was brought home to me when I added 64M of RAM to my 32M
system.  With only 32M I rarely swapped--only when compiling the
kernel and running netscape or applix or something like that.

Then I had 96M and took a look at top and I had used 94M of RAM!
Considering that I'd never used that much RAM+swap before I was
startled.  But then the above explanation occurred to me.  It's true.
Try running emacs.  Now quit it and rerun it.  Comes up much faster
the second time, doesn't it?

--
Michael D, Hirsch                       Work: (404) 727-4969
Emory University, Atlanta, GA 30322     FAX: (404) 727-5611

Public key for encrypted mail available upon request (or finger

 
 
 

I am puzzled by the way Linux releases memory, please explain.

Post by David F » Fri, 06 Feb 1998 04:00:00





> >When I look at the output of "free" in an untax Linux system it typically
> >resembles the following:

> >             total       used       free      shared      buffers    cached
> >Mem:         63104      17592      45512      20240       1060       9000
> >-/+ buffers/cache:       7532      55572
> >Swap:        68540          0      68540

> You should concentrate on the 2nd column (-/+) and read the "free"
> value there. That is what _really_ is available.

A good point.  It might be worth redesigning the output of free to
express this in a way that is immediately clear - I never took the
time to figure out what that middle line meant when it appeared.
I still don't really know why it says "+/- buffers/cache"
--
David Fox          http://www.cat.nyu.edu/fox            xoF divaD

 
 
 

1. Please Explain IO Memory

Hello --

I'm trying to understand how Linux addresses kernel memory for a
device driver I'm writing.  The device communicates with the PC via a
shared memory area, which is located, according to the device's
manual, at 0xD000.  This is a real-mode address and, translated into a
32-bit address, it should be 0xD0000.  If I wanted to set the first
byte in the shared memory area to 0, would it be fine, then, to say
writeb( 0, 0xD0000 )?  Or do I have to make some additional
conversion?  And will this work on intel-only, or all architectures?

Also, is there any way to register a block of IO memory with the
kernel, so other devices don't write to it, or a way to check whether
or not a given bit of IO memory is already in use?  My driver, as is,
crashes quite frequently, and I'm wondering if this might be because
I'm writing to IO memory also used by another card.  (Because all the
cards except the one for which I'm writing the driver are PCI, I have
no way of knowing what memory address they have been dynamically
assigned to.  Any way around that?)

Thanks for the help!

-Chris

2. herrno erro Linux 2.0.29

3. explain memory model for linux

4. crypt

5. can somebody explain how linux support 64G memory

6. Roles and how to

7. ** Linux documents explained for Newbies (please read) **

8. Java follow-up

9. memory usage puzzle

10. Strange Memory Puzzle.

11. Memory error puzzle

12. Explain KDE please...........

13. TCP: please explain it to me...