Re: Strange memory leak??

Benjamin Redelings I (bredelin@ucsd.edu)
Tue, 16 Feb 1999 16:08:51 +0000


I am not sure that you have a memory problem: I think its just the
"free" doesn't mean what you expect in these circumstances. In any
case, I suggest that you try Alan Cox's patch-2.2.1-ac6, which should
increase performace significantly on large-memory systems by making sure
that buffers only take up a certain percentage of memory. (2.2.2-pre4
has a small but IMPORTANT bug in this area, so either get 2.2.1-ac6 or
apply the small patch posted by Stephen Tweedie on the linux-kernel list
to 2.2.2-pre4).

BTW, I just learned about the command 'vmstat 1', which is quite
usefull in debugging memory or virtual memory problems. Top is
basically useless.. its output can be very misleading. The 'free'
command is good.

Basically "free" memory is memory that is not being used AT ALL: not
only is it not storing code or data, but its also not in the buffer
cache or the page cache. The Linux philosophy is "free memory is wasted
memory", which is a very good philosophy. Linux tries to keep a certain
amount of memory (about 3% ?) free at all times to improve
interativeness by responding quickly to requests for free pages.
However, any other unused memory can be used by the buffer cache or the
page cache UNTIL IT IS NEEDED.
So the buffer memory and the page cache memory should be reclaimed. I
usually use a program like 'xquake' to check this, because it sucks up a
lot of memory and usually causes the flushing of lots of buffers in the
process.

-------------(Why your results are no alarming)--------------------
1) For example, the output from 'free' seems perfectly reasonable:
and after building, free shows ...

[steelhead] [/home/gwhalin] > free
total used free shared buffers
cached
Mem: 257976 229472 28504 7752 100368
111396
-/+ buffers/cache: 17708 240268
Swap: 128484 0 128484

You see, the first line doesn't mean much unless you are a kernel hacker
:) You need to look at the "-/+ buffers/cache" line. BTW, I think that
'shared' refers to pages that are both in the page cache and allocated
normally.

2) You see, this simply doesn't mean much. The '229588K used' gives you
very little information, because this includes the "101616K buff", which
should be free on demand. Don't use 'top'. Use 'free' or 'vmstat 1'.

17. After complete logoff and new loging.
Mem: 257972K av, 229588K used, 28384K free, 7868K shrd, 101616K buff

3) BTW, the GNU C compiler has been known to such up enormous amounts of
memory when processing templates. I have not heard of any reports of
this for a while. If that is the problem, then you need to talk to the
people at http://egcs.cygnus.com/. They have a mailing list and
archives...

After trying 2.2.1-ac6, do you have any problems with buffer not being
freed when memory is needed?

-BenRI

-- 
"What's the meaning of life?  (Answer in 6 words or less)"

Benjamin Redelings I <>< http://sdcc13.ucsd.edu/~bredelin

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/