Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory leakage?

2 views
Skip to first unread message

Jeffrey Sink

unread,
Mar 15, 1998, 3:00:00 AM3/15/98
to

I am running LInux RedHat 4.2 (2.30 kernel, I think), with MetroX window
manager, and have a good bit of memory (96M).

I recently upgraded from 32M and it seems that the system has just
completely used up all the additional memory.

if I run free:

total used free shared buffers cached
Mem: 95636 80716 14920 24056 20932 35252
-/+ buffers: 24532 71104
Swap: 33228 0 33228


But nothing interesting is running. Nothing that did not run on 32M, that
is for sure. I tried quiting out of X to see if that would do it, but to
no success.

Is there a way to have Linux "purge" memory?

the output of 'top', sorting by memory usage:

5:00am up 13:11, 4 users, load average: 0.14, 0.06, 0.07
37 processes: 35 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 1.3% user, 0.5% system, 1.7% nice, 98.3% idle
Mem: 95636K av, 73344K used, 22292K free, 18668K shrd, 20932K buff
Swap: 33228K av, 0K used, 33228K free 35240K cached

PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
4667 root 17 0 7084 7084 796 R 0 0.5 7.4 1:12 X
5009 root 1 0 1720 1720 1320 S 0 0.1 1.7 0:00 xterm
4848 root 0 0 1680 1680 1292 S 0 0.0 1.7 0:00 nxterm
4668 root 0 0 1456 1456 1288 S 0 0.0 1.5 0:00 xdm
4850 jsink 16 16 1376 1376 1096 S N 0 0.0 1.4 0:00 xload
4679 jsink 1 0 1188 1188 844 S 0 0.0 1.2 0:01 fvwm95-2
4665 root 0 0 968 968 868 S 0 0.0 1.0 0:00 xdm
4638 root 0 0 928 928 528 S 0 0.0 0.9 0:00 tcsh
4846 jsink 0 0 836 836 676 S 0 0.0 0.8 0:00 FvwmTaskBa
4849 jsink 0 0 808 808 516 S 0 0.0 0.8 0:00 tcsh
5011 root 0 0 808 808 520 S 0 0.0 0.8 0:00 tcsh

--
Jeffrey M. Sink
js...@umich.edu

Christopher B. Browne

unread,
Mar 15, 1998, 3:00:00 AM3/15/98
to

On Sun, 15 Mar 1998 10:01:53 GMT, Jeffrey Sink <js...@lsa.umich.edu> posted:

>
>I am running LInux RedHat 4.2 (2.30 kernel, I think), with MetroX window
>manager, and have a good bit of memory (96M).
>
>I recently upgraded from 32M and it seems that the system has just
>completely used up all the additional memory.
>
>if I run free:
>
> total used free shared buffers cached
>Mem: 95636 80716 14920 24056 20932 35252
>-/+ buffers: 24532 71104
>Swap: 33228 0 33228
>
>
>But nothing interesting is running. Nothing that did not run on 32M, that
>is for sure. I tried quiting out of X to see if that would do it, but to
>no success.
>
>Is there a way to have Linux "purge" memory?

Everything is working just *fine*.

You've got 15MB of memory that hasn't been touched (the 14920 in the "free"
column).

Note that you've got 35MB of "cached" data. What this means is that things
that you've read off disk before are still in memory so that if you read
them again (e.g. - rerun the program) they will still be in memory. This
means they will not need to be reread off disk, but merely copied from one
area of RAM to another, which is *gloriously* faster.

The only problem that you may have is that you've got nearly 16MB of memory
that you paid for that you may not truly need...

--
Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer <http://www.hex.net/~cbbrowne/lsf.html>
cbbr...@hex.net - "What have you contributed to Linux today?..."

KLZEng

unread,
Mar 15, 1998, 3:00:00 AM3/15/98
to

>I recently upgraded from 32M and it seems that the system has just
>completely used up all the additional memory.
>
>if I run free:
>
> total used free shared buffers cached
>Mem: 95636 80716 14920 24056 20932 35252
>-/+ buffers: 24532 71104
>Swap: 33228 0 33228
>
>
>But nothing interesting is running. Nothing that did not run on 32M, that
>is for sure.

Linux will keep a running cache (notice the last entry in the table) of all the
programs that it has run. This cache will continue to use available RAM up to
n-512K I believe (someone correct me in this if I am wrong).

The reason that it caches so much is to reduce the amount of time necessary for
retrieving information from the filesystems. Though this may seem almost moot
considering the speed of todays hard disks, think how much more performance you
achieve when Linux is connected to a slow network!

Ergo fret not the seeming wasted space! If Linux really needs that space, it
will automatically purge the memory!

Ed

Nix

unread,
Mar 15, 1998, 3:00:00 AM3/15/98
to

In article <19980315151...@ladder03.news.aol.com>,

KLZEng <klz...@aol.com> wrote:
>>I recently upgraded from 32M and it seems that the system has just
>>completely used up all the additional memory.
>>
>>if I run free:
>>
>> total used free shared buffers cached
>>Mem: 95636 80716 14920 24056 20932 35252
>>-/+ buffers: 24532 71104
>>Swap: 33228 0 33228
>>
>
>Linux will keep a running cache (notice the last entry in the table) of all the
>programs that it has run. This cache will continue to use available RAM up to
>n-512K I believe (someone correct me in this if I am wrong).

Er, not quite. That's a dynamically resizable disk cache. There's also a
buffer cache involved, eating another 20Mb. That's dynamically resizable too,
although it tends to be smaller than the disk cache.

I'm not sure about the numbers; someone better than I at the internals of
the kernel will have to respond here, I think.

>The reason that it caches so much is to reduce the amount of time necessary for
>retrieving information from the filesystems.

Indeed. It's sometimes damn annoying... on my box, for instance:

Mem: 7168000 6971392 196608 3059712 176128 2179072
Swap: 66625536 17817600 48807936

7Mb total RAM after the kernel's loaded, and 2.5Mb of that is eaten in disk
cache. 2.0.29 never used to cache this aggressively; it can be annoying, as
the cache never shrinks very much even when something is thrashing. :(

> Though this may seem almost moot
>considering the speed of todays hard disks, think how much more performance you
>achieve when Linux is connected to a slow network!

I don't think it's moot. Perhaps surviving with an 8Mb box and regularly
visiting Swap City and the Plaza of the Page Fault would convince you that
even fast HDDs really aren't that fast.

One thing I read once put this very neatly:

`When you hit a page fault, suddenly you're transported from a world of
racing electrons and microsecond timings into a world which depends on
moving a bit of metal around on the end of a stick. The effect is as if
you were to instantly halt your 200mph Ferrari and ask your grandmother
to get out and push.'

>Ergo fret not the seeming wasted space! If Linux really needs that space, it
>will automatically purge the memory!

... down to about 2Mb :(((

But I agree; `free' memory is wasted memory.

--
`Oooo! Saint Malcolm preserve us! This is heresy.'

Lars Hofhansl

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to

Jeffrey Sink wrote:
>
> I am running LInux RedHat 4.2 (2.30 kernel, I think), with MetroX window
> manager, and have a good bit of memory (96M).
>
> I recently upgraded from 32M and it seems that the system has just
> completely used up all the additional memory.
>
> if I run free:
>
> total used free shared buffers cached
> Mem: 95636 80716 14920 24056 20932 35252
> -/+ buffers: 24532 71104
> Swap: 33228 0 33228
>
> But nothing interesting is running. Nothing that did not run on 32M, that
> is for sure. I tried quiting out of X to see if that would do it, but to
> no success.
>
> Is there a way to have Linux "purge" memory?
>

Believe me, you wouldn't want to purge it! Free memory is wasted
memory.
You should be worried about 14megs still being unused. Why aren't
those used for disk-caching etc?
Of course I'm exagerating here, but the point still holds.

What Linux does is using all the free memory as disk and page
cache. This cache will be released as soon as an application
requests more memory which can't be served from the free pages pool.
So don't worry... :)

Cheers,

Lars

--
Legal Warning: Anyone sending me unsolicited/commercial email
WILL be charged a $100 proof-reading fee. See US Code Title 47,
Sec.227(a)(2)(B), Sec.227(b)(1)(C) and Sec.227(b)(3)(C).

Charles Herman

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to

Jeffrey Sink wrote:

> I am running LInux RedHat 4.2 (2.30 kernel, I think), with MetroX window
> manager, and have a good bit of memory (96M).
>
> I recently upgraded from 32M and it seems that the system has just
> completely used up all the additional memory.
>
> if I run free:
>
> total used free shared buffers cached
> Mem: 95636 80716 14920 24056 20932 35252
> -/+ buffers: 24532 71104
> Swap: 33228 0 33228
>
> But nothing interesting is running. Nothing that did not run on 32M, that
> is for sure. I tried quiting out of X to see if that would do it, but to
> no success.
>
>

> --
> Jeffrey M. Sink
> js...@umich.edu

I recently upgraded from 32MB to 80MB. When I do a free I get

total used free shared buffers
cached

Mem: 64188 60560 3628 20104 5960 14944
-/+ buffers: 39656 24532
Swap: 72256 5488 66768

When I boot, the BIOS knows I have 80MB, Win95 knows I have 80MB, why does free
report only 64MB? Does this mean Linux is not using the additional 16MB?
I have RedHat 3.0.3, the kernel has been uipgraded to 2.0.0.

-Charles
Please repond to this newsgroup.


Ian Burrell

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to

In article <350D9730...@no.spam>, Charles Herman <sp...@no.spam> wrote:
>
> I recently upgraded from 32MB to 80MB. When I do a free I get
>
> total used free shared buffers
>cached
>Mem: 64188 60560 3628 20104 5960 14944
>-/+ buffers: 39656 24532
>Swap: 72256 5488 66768
>
>When I boot, the BIOS knows I have 80MB, Win95 knows I have 80MB, why does free
>report only 64MB? Does this mean Linux is not using the additional 16MB?
>I have RedHat 3.0.3, the kernel has been uipgraded to 2.0.0.
>

Unless you are running a most recent 2.1.x kernel, Linux can't detect
memory above 64MB. When you boot, it should say it only detects 64MB
of memory.

The solution is to tell the kernel how much memory you have. Add this
line to /etc/lilo.conf

append="mem=80M"

and rerun lilo.


- Ian

--
ibur...@leland.stanford.edu http://www-leland.stanford.edu/~iburrell/
No matter how much you know, you will never know enough.

Torsten Poulin Nielsen

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to

In article <350D9730...@no.spam>, Charles Herman wrote:

>When I boot, the BIOS knows I have 80MB, Win95 knows I have 80MB, why does free
>report only 64MB? Does this mean Linux is not using the additional 16MB?
>I have RedHat 3.0.3, the kernel has been uipgraded to 2.0.0.

Add something like this stanza to your /etc/lilo.conf:

append = "mem=80M"

-Torsten


Yann Vernier

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to

On Mon, 16 Mar 1998, Charles Herman wrote:

> Jeffrey Sink wrote:
>
> > I am running LInux RedHat 4.2 (2.30 kernel, I think), with MetroX window
> > manager, and have a good bit of memory (96M).
> >
> > I recently upgraded from 32M and it seems that the system has just
> > completely used up all the additional memory.
> >

Have you noticed how much is in "buffers" and "cached"? This is actually
free memory which is used for buffering since there's nothing else using
the memory. Thus your system runs faster with more memory, even when not
using a lot (in programs).


>
> I recently upgraded from 32MB to 80MB. When I do a free I get
>
> total used free shared buffers
> cached
> Mem: 64188 60560 3628 20104 5960 14944
> -/+ buffers: 39656 24532
> Swap: 72256 5488 66768
>

> When I boot, the BIOS knows I have 80MB, Win95 knows I have 80MB, why does free
> report only 64MB? Does this mean Linux is not using the additional 16MB?

> -Charles
>
This is another issue. The original AT BIOS (which was the first to report
more memory than 640KB) gave a 16-bit integer, which was the number of
kilobytes above 1MB. This allowed for 65MB of RAM, which sure is a lot.
Some memory managers even treated this as a signed value (for instance,
Windows 3.0) since noone could ever get hold of more than 32MB, right? Not
anymore. However, the Linux kernel doesn't test for more memory by default
(the 2.1 kernels test for the new BIOS calls which can report more memory,
though) so you'll only get 64MB. The simple and not too inelegant solution
is to add the parameter "mem=XXm" on the boot prompt (i.e. loadlin command
line, LILO append= command) so that Linux uses XX megabytes of memory. Be
sure not to give it a higher value than you actually have. Lower values
will limit Linux to using only that much memory and ignoring the rest.


ben...@xs4all.nl

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to

Charles Herman <sp...@no.spam> wrote:
> When I boot, the BIOS knows I have 80MB, Win95 knows I have 80MB, why does free
> report only 64MB? Does this mean Linux is not using the additional 16MB?

yes. you can add an option to linux (lilo) that says you have 80 MB.

> Please repond to this newsgroup.

of course. where else ?

--
Grobbebol's Home | Don't give in to spammers.
http://www.xs4all.nl/~bengel | Use your real e-mail address
Linux 2.0.33 on an i586/64 MB | on Usenet.

gerald clark

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to

Jeffrey Sink wrote:
>
> I am running LInux RedHat 4.2 (2.30 kernel, I think), with MetroX window
> manager, and have a good bit of memory (96M).
>
> I recently upgraded from 32M and it seems that the system has just
> completely used up all the additional memory.
>
> if I run free:

>
> total used free shared buffers cached
> Mem: 95636 80716 14920 24056 20932 35252
> -/+ buffers: 24532 71104
> Swap: 33228 0 33228
>
> But nothing interesting is running. Nothing that did not run on 32M, that
> is for sure. I tried quiting out of X to see if that would do it, but to
> no success.
>
> Is there a way to have Linux "purge" memory?
What for? You have 71M free sitting in buffers that will get allocated
to any
process that wants memory. Linux has to keep it somewhere, so it is
temporarily
on load to buffers.

>
> the output of 'top', sorting by memory usage:
>
> 5:00am up 13:11, 4 users, load average: 0.14, 0.06, 0.07
> 37 processes: 35 sleeping, 2 running, 0 zombie, 0 stopped
> CPU states: 1.3% user, 0.5% system, 1.7% nice, 98.3% idle
> Mem: 95636K av, 73344K used, 22292K free, 18668K shrd, 20932K buff
> Swap: 33228K av, 0K used, 33228K free 35240K cached
>
> PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
> 4667 root 17 0 7084 7084 796 R 0 0.5 7.4 1:12 X
> 5009 root 1 0 1720 1720 1320 S 0 0.1 1.7 0:00 xterm
> 4848 root 0 0 1680 1680 1292 S 0 0.0 1.7 0:00 nxterm
> 4668 root 0 0 1456 1456 1288 S 0 0.0 1.5 0:00 xdm
> 4850 jsink 16 16 1376 1376 1096 S N 0 0.0 1.4 0:00 xload
> 4679 jsink 1 0 1188 1188 844 S 0 0.0 1.2 0:01 fvwm95-2
> 4665 root 0 0 968 968 868 S 0 0.0 1.0 0:00 xdm
> 4638 root 0 0 928 928 528 S 0 0.0 0.9 0:00 tcsh
> 4846 jsink 0 0 836 836 676 S 0 0.0 0.8 0:00 FvwmTaskBa
> 4849 jsink 0 0 808 808 516 S 0 0.0 0.8 0:00 tcsh
> 5011 root 0 0 808 808 520 S 0 0.0 0.8 0:00 tcsh
>

> --
> Jeffrey M. Sink
> js...@umich.edu

--
Remove the -bogus- portions of my return address!

Roelf Diedericks

unread,
Mar 18, 1998, 3:00:00 AM3/18/98
to

Jeffrey Sink wrote in message ...


>
>I am running LInux RedHat 4.2 (2.30 kernel, I think), with MetroX window
>manager, and have a good bit of memory (96M).

>I recently upgraded from 32M and it seems that the system has just
>completely used up all the additional memory.


The memory gets used for the Linux disk cache...
The philosophy is something like this:

'If the memory isn't being used by a process, why the heck not use it for a
disk
cache?'

If a process does need the memory, Linux will simply shrink the cache.

Unused memory = wasted memory ;)

>Is there a way to have Linux "purge" memory?


Not really...

Regards,
Roelf.
e-mail: ro...@ttdesk.co.za
www: http://www.ttdesk.co.za/~roelf

Robin Faye Wright

unread,
Mar 18, 1998, 3:00:00 AM3/18/98
to

If Linux 2.0.x has a memory limit of 64MB, is there a memory limit in
Linux 2.1.x as well? If so, what is that limit?

-Robin

Ian Burrell

unread,
Mar 18, 1998, 3:00:00 AM3/18/98
to

In article <351034...@cps.msu.edu>,

Robin Faye Wright <wrig...@cps.msu.edu> wrote:
>If Linux 2.0.x has a memory limit of 64MB, is there a memory limit in
>Linux 2.1.x as well? If so, what is that limit?
>

It isn't a memory limit. You can have up to 1GB of RAM under 2.0.x.
The kernel just can't detect the amount of RAM over 64MB because it
uses a old BIOS call (which I think returns a 16bit number of 4KB
pages). So the kernel must be told how much there actually is, but it
will use all that RAM with no problem.

2.1.x fixes this problem by using a new BIOS call. Also, the memory
limit has been expanded to 2GB.


- Ian

--
ibur...@leland.stanford.edu http://www-leland.stanford.edu/~iburrell/
Murphy's Law: Anything that can go wrong, will.

David Lee

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

gerald clark (gclark-bogus-@-bogus-iconnect.net) wrote:
: What for? You have 71M free sitting in buffers that will get allocated

: to any
: process that wants memory. Linux has to keep it somewhere, so it is
: temporarily
: on load to buffers.

Is there any way in kernel to reclam the memory allocated for
buffer? Will kmalloc(), __get_free_pages() do that?

-- David Lee


Peter Steiner

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

On Wed, 18 Mar 1998 15:56:27 -0500, Robin Faye Wright <wrig...@cps.msu.edu>
wrote:

>If Linux 2.0.x has a memory limit of 64MB,

AFAIK the memory limit of Linux 2.0.x is about 1GB. It just can't
automatically detect more than 64MB.

Ciao,

Peter
--
_ x ___
/ \_/_\_ /,--' p.st...@t-online.de (Peter Steiner)
\/>'~~~~//
\_____/ signature V0.2 alpha

ben...@xs4all.nl

unread,
Mar 20, 1998, 3:00:00 AM3/20/98
to

Robin Faye Wright <wrig...@cps.msu.edu> wrote:
> If Linux 2.0.x has a memory limit of 64MB, is there a memory limit in
> Linux 2.1.x as well? If so, what is that limit?

he wrote that the auto detection is limited to 64 MB. it doesn't say that
the actual lilit _is_ 64 MB. you can override it with mem=.. options for
lilo.

Kir Kolyshkin

unread,
Mar 25, 1998, 3:00:00 AM3/25/98
to


Charles Herman wrote:

> I recently upgraded from 32MB to 80MB. When I do a free I get
>

> total used free shared buffers
> cached

> Mem: 64188 60560 3628 20104 5960 14944
> -/+ buffers: 39656 24532
> Swap: 72256 5488 66768
>

> When I boot, the BIOS knows I have 80MB, Win95 knows I have 80MB, why does free
> report only 64MB? Does this mean Linux is not using the additional 16MB?

> I have RedHat 3.0.3, the kernel has been uipgraded to 2.0.0.
>

> -Charles


> Please repond to this newsgroup.

There's a special boottime parameter to teh kernel in /etc/lilo.conf which can be
used to specify the amount of memory actually installed in our machine.
BootPromptHOWTO will tell you about this...

--
Kirill Kolyshkin, Severtelecom, General Technical Manager
mailto:k...@sever.net http://kir.sever.net ICQ 7551596
Office phone: +7 82147 45979 Home phone: +7 82147 35695
"Software is like sex ... it's better when it's free"
Linus Torvalds

Bernd Paysan

unread,
Mar 26, 1998, 3:00:00 AM3/26/98
to

Ian Burrell wrote:
> 2.1.x fixes this problem by using a new BIOS call. Also, the memory
> limit has been expanded to 2GB.

The memory limit in 2.1.90 is configurable, you can have up to 3.8GB or
even a bit more. Note that you need some unused memory space for PCI
mapping.

--
Bernd Paysan
"Late answers are wrong answers!"
http://www.jwdt.com/~paysan/

Bernd Paysan

unread,
Mar 26, 1998, 3:00:00 AM3/26/98
to

Roelf Diedericks wrote:
> >Is there a way to have Linux "purge" memory?
>
> Not really...

Write a small memhog program that mallocs a huge buffer, writes a byte
every page and then terminates. This will for sure "purge" memory... But
you won't need it.

void main() {
char * l=malloc(0x1000000); int i;
for (i=0; i<0x1000000; i+= 0x1000) l[i]='x';
}

will "purge" 16MB for you.

Erkki Seppala

unread,
Mar 29, 1998, 3:00:00 AM3/29/98
to

Bernd Paysan <bernd....@remove.muenchen.this.org.junk> writes:

> > >Is there a way to have Linux "purge" memory?

A quick solution with some shells (bash, zsh) is to hit alt-10000000
and space.. Not quite as fast (and elegant ;) ) as a mem-hog-program,
but it works ;).

--
_____________________________________________________________________
/ __// /__ ____ __ Erkki Seppälä\ \
/ /_ / // // /\ \/ / Inside Informatics ry\ /
/_/ /_/ \___/ /_/\_\@inside.org http://www.inside.org/~flux\/

Roy Stogner

unread,
Mar 30, 1998, 3:00:00 AM3/30/98
to

On 29 Mar 1998 19:18:37 +0300, Erkki Seppala <fl...@xulfad.tes> wrote:
>Bernd Paysan <bernd....@remove.muenchen.this.org.junk> writes:
>
>> > >Is there a way to have Linux "purge" memory?
>
>A quick solution with some shells (bash, zsh) is to hit alt-10000000
>and space.. Not quite as fast (and elegant ;) ) as a mem-hog-program,
>but it works ;).

OK... I did so (although I may have been off by factor of 10 on the
exact number... I gather that was important, now), I killed the shell
when xload reached two and when my hard drive was in constant motion,
and I observed some very interesting behavior (specifically, gobs of
unused RAM for a short time) with free afterward.

What did I just do to my computer?
---
Roy Stogner

Erkki Seppala

unread,
Apr 9, 1998, 3:00:00 AM4/9/98
to

royst...@SPAMiname.com (Roy Stogner) writes:

> On 29 Mar 1998 19:18:37 +0300, Erkki Seppala <fl...@xulfad.tes> wrote:

> >A quick solution with some shells (bash, zsh) is to hit alt-10000000
> >and space.. Not quite as fast (and elegant ;) ) as a mem-hog-program,

> OK... I did so (although I may have been off by factor of 10 on the


> exact number... I gather that was important, now), I killed the shell

You probably did. 10000000 is just ~10 megabytes. (Although I suspect
shells might use more than one byte/character, dunno for sure..)

> when xload reached two and when my hard drive was in constant motion,
> and I observed some very interesting behavior (specifically, gobs of
> unused RAM for a short time) with free afterward.

> What did I just do to my computer?

What that does that it enters 10 million spaces to the input buffer,
and naturally reserves the memory for it. If you entered one extra
zero, you (tried to) reserve 100 megabytes, and unless you have
plenty'o memory, it began swapping hard..

After you discarded the line (or killed the shell) all the memmory
allocated by the buffer was freed. Unless there is much hd-activity
io-buffers aren't going to eat that free space immediately..

Load was increased because of the swapping: programs trying to access
the hd were blocked, as there were other uses for it..

0 new messages