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

Memory usage

9 views
Skip to first unread message

Carmine F. Greco

unread,
Dec 28, 2001, 6:27:10 PM12/28/01
to
I recently added 256MB to my machine to bring the total memory to 512MB
RAM so that I would have plenty of extra room for apps. However, gtop is
showing that 400+MB are being used by the processes from startup (i.e.,
X, nautilus, etc.) When I had 256MB, these processes would also take up
about 80% of memory according to the indicators. Are these memory usage
indicators correct? If not, is there any way to really know how much memory
is acutally being used?
Thanks.

Carmine

Dragan Colak

unread,
Dec 28, 2001, 7:41:25 PM12/28/01
to
Carmine F. Greco wrote:

Do a 'cat /proc/meminfo'.
You will see that your RAM is not used by processes only, but by caches.
That speeds up the overall performance of your system. There is no need to
let large parts of the memory stay empty (waste of resources).
The size of those caches is dynamic, so if you start an app that needs a lot
of RAM the system reduces the size of the caches.

HTH

Dragan

Ming He

unread,
Dec 29, 2001, 5:35:20 AM12/29/01
to
Dragan Colak wrote:

> Do a 'cat /proc/meminfo'.
> You will see that your RAM is not used by processes only, but by caches.
> That speeds up the overall performance of your system. There is no need to
> let large parts of the memory stay empty (waste of resources).
> The size of those caches is dynamic, so if you start an app that needs a lot
> of RAM the system reduces the size of the caches.
>
> HTH

First things first, what is "HTH"? "Have To Hack"?

How to control the size of cache, so I got more free mem?

[ming@eye ming]$ free
total used free shared buffers cached
Mem: 32356 31732 624 0 652 13572
-/+ buffers/cache: 17508 14848
Swap: 146704 8360 138344

And why my shared is always 0? This is kernel 2.2.19. When I was at 2.2.14, I
remember I got quite some shared reported.

/ming

Tony Lawrence

unread,
Dec 29, 2001, 6:35:49 AM12/29/01
to
Ming He wrote:

> Dragan Colak wrote:
>
>
>>Do a 'cat /proc/meminfo'.
>>You will see that your RAM is not used by processes only, but by caches.
>>That speeds up the overall performance of your system. There is no need to
>>let large parts of the memory stay empty (waste of resources).
>>The size of those caches is dynamic, so if you start an app that needs a lot
>>of RAM the system reduces the size of the caches.
>>
>>HTH
>>
>
> First things first, what is "HTH"? "Have To Hack"?
>
> How to control the size of cache, so I got more free mem?


You aren't understanding- "free" ram will be snagged for buffer cache.
When you need it for your apps, the kernel gives it back.

All self-adjusting.


--
Tony Lawrence
SCO/Linux Support Tips, How-To's, Tests and more: http://pcunix.com

David E Fox

unread,
Dec 29, 2001, 4:04:43 PM12/29/01
to
Ming He wrote:

> First things first, what is "HTH"? "Have To Hack"?

'hope this helps'

> How to control the size of cache, so I got more free mem?

Probably you need to stop using the same things over and over again.
That will reduce the size of cache. :) Linux allocates this dynamically,
based on your usage. So, if you use more disk resources, your buffers
go up, or if you make frequent calls to the same programs, the memory
cache resources adjust upwards accordingly.

> And why my shared is always 0? This is kernel 2.2.19. When I was at
> 2.2.14, I remember I got quite some shared reported.

I've also wondered about this. For instance, under previous kernels,
I might see quite a lot - even upwards of 100 megs - in 'shared'
after starting some big WM like KDE. But lately, that is no longer
true. One would expect to see something in 'shared' if I understand
what it's for -- areas of memory that are shared between processes
(either multiple instances of them, like all your 'bash' sessions, or
portions of libraries that are shared between processes).

>
> /ming
>
--
------------------------------------------------------------------------
David E. Fox Thanks for letting me
df...@tsoft.com change magnetic patterns
df...@m206-157.dsl.tsoft.com on your hard disk.
-----------------------------------------------------------------------

Bob Hauck

unread,
Dec 29, 2001, 9:11:15 PM12/29/01
to
On Sat, 29 Dec 2001 10:35:20 GMT, Ming He <mi...@hotmail.com> wrote:
> Dragan Colak wrote:

>> The size of those caches is dynamic, so if you start an app that needs a
>> lot of RAM the system reduces the size of the caches.
>>
>> HTH
>
> First things first, what is "HTH"? "Have To Hack"?

Hope This Helps.


> How to control the size of cache, so I got more free mem?

What for? The kernel will take memory from the cache if it needs to.
The short of it is that cache is not permanently dedicated like some
other systems. That's what he meant by "the size of those caches is
dynamic" up above.

There are some tuning options to tweak the algorithm the kernel uses for
sizing cache, but I don't recall them offhand as I've never had to use
them.


> And why my shared is always 0? This is kernel 2.2.19.

Uh, dunno about that one. I'm running 2.2.19 and 2.2.20 and free shows
shared on both here. Must be some patch or kernel option that one of
us has and the other doesn't.

--
-| Bob Hauck
-| To Whom You Are Speaking
-| http://www.haucks.org/

Tauno Voipio

unread,
Dec 30, 2001, 5:45:00 AM12/30/01
to

"Bob Hauck" <b...@this-is.invalid> wrote in message
news:slrna2ss9...@finch.haucks.org...

> > And why my shared is always 0? This is kernel 2.2.19.
>
> Uh, dunno about that one. I'm running 2.2.19 and 2.2.20 and free shows
> shared on both here. Must be some patch or kernel option that one of
> us has and the other doesn't.
>

There have been problems reporting shared memory in versions after 2.2.14.
The shared memory works, but it reports as zero.

Tauno Voipio
tauno voipio @ iki fi


Ming He

unread,
Dec 30, 2001, 5:41:16 PM12/30/01
to
Ming He wrote:

>
> How to control the size of cache, so I got more free mem?
>

The major replay says, "don't warry, the cache is actually, (and part of it), is
your free memory, they were dynamically allocated".

I know that.

The things is, I want to ***control*** how dynamic it is. Not let the OS decide
it for me.

Like, where I can set (min_cache_size [or persentage], max_cache_size [or
persentage]), (min_buffer_size [or persentage], max_buffer_size [or persentage]).

I think, with a small disk cache, I can reduce the memory paging to disk. Which
will help the performance when you switching among some large programs.

/ming

Carl Fink

unread,
Dec 30, 2001, 6:01:21 PM12/30/01
to
On Sun, 30 Dec 2001 22:41:16 GMT Ming He <mi...@hotmail.com> wrote:

>I think, with a small disk cache, I can reduce the memory paging to disk. Which
>will help the performance when you switching among some large programs.

And you are *wrong*. Linux's habit of using all available RAM for cache
*does not increase paging*.
--
Carl Fink ca...@dm.net
Manager, Dueling Modems Computer Forum
<http://dm.net>

Bob Hauck

unread,
Dec 30, 2001, 8:14:27 PM12/30/01
to
On Sun, 30 Dec 2001 22:41:16 GMT, Ming He <mi...@hotmail.com> wrote:

> I think, with a small disk cache, I can reduce the memory paging to disk.

<http://www.linuxhq.com/kernel/v2.4/doc/sysctl/vm.txt.html>

Have fun.

Ming He

unread,
Dec 30, 2001, 10:51:08 PM12/30/01
to
Carl Fink wrote:

> On Sun, 30 Dec 2001 22:41:16 GMT Ming He <mi...@hotmail.com> wrote:
>
> >I think, with a small disk cache, I can reduce the memory paging to disk. Which
> >will help the performance when you switching among some large programs.
>
> And you are *wrong*. Linux's habit of using all available RAM for cache
> *does not increase paging*.

[ming@eye /etc]$ free


total used free shared buffers cached

Mem: 32356 31704 652 0 684 10376
-/+ buffers/cache: 20644 11712
Swap: 146704 11828 134876


Let's read this a bit.

32 MB, 650 KB free, 684 KB buffer, (well, forgot what's buffer for, for write to
disk?), 10 MB cache, 11 MB swap used.

So about 20 MB for loading program.

I did a 'ps' and figure most system startup services already swpped to that 11 MB
disk.

This 10 MB cache, should include some disk read ahead cache and some cache for swap
file (don't know about read or write).

I think I'm happy with 4 MB cache. So I can gett 6 MB more memory, for more
programs to stay in memory.

**My question is how to limit the size of cache**.

So if I'm wrong, please explain more on "Linux's habit of using all available RAM
for cache
*does not increase paging*". Because I figure that 10 MB is not all that available.

This should not be a concern for machines with 128+ MB memory.

BTW, I think 2.2.19 manage memory quite more efficient than 2.2.14. And the memory
RSS reported is same from 'ps' and 'top' now.

/ming

Ming He

unread,
Dec 30, 2001, 11:00:29 PM12/30/01
to
Bob Hauck wrote:

> On Sun, 30 Dec 2001 22:41:16 GMT, Ming He <mi...@hotmail.com> wrote:
>
> > I think, with a small disk cache, I can reduce the memory paging to disk.
>
> <http://www.linuxhq.com/kernel/v2.4/doc/sysctl/vm.txt.html>
>

Hey, give up on replying direct to you, the email address is too complicated.
;-)

From that **v.2.4** page.

Documentation for /proc/sys/vm/* kernel version 2.2.10 <------<<<<
(c) 1998, 1999, Rik van Riel

Hmmm, so where is the vm.txt for 2.4 online? localhost: /usr/src/linux_2.4/
only?

/ming

Carl Fink

unread,
Dec 31, 2001, 1:27:15 AM12/31/01
to
First of all: please do NOT copy me by email when posting. I'm sure you
meant well, but it is not doing me a favor: it's just adding to my
workload. Thank you.

On Mon, 31 Dec 2001 03:51:08 GMT Ming He <mi...@hotmail.com> wrote:

[snip]


>I did a 'ps' and figure most system startup services already swpped to that 11 MB
>disk.
>

>So if I'm wrong, please explain more on "Linux's habit of using all
>available RAM for cache *does not increase paging*". Because I figure that
>10 MB is not all that available.

And you're right, taken very literally. However, most of it is. The Linux
kernel automatically dumps the surplus disk cache when that RAM is needed
for program or data. Just reassigning it from cache to code has essentially
no overhead, so there's no reason to leave it unassigned, and good reason to
at least take the *chance* that using it as cache might speed things up.

Yes, long-unrun programs are swapped even when RAM is available. That's
Linux making more RAM available for other uses, pre-emptively. Feature, not
bug.

ynotssor

unread,
Dec 31, 2001, 3:32:17 AM12/31/01
to
"Ming He" <mi...@hotmail.com> quoted and wrote in message
news:3C2FE2E6...@hotmail.com...
[...]

> > > I think, with a small disk cache, I can reduce the memory paging to disk.
> >
> > <http://www.linuxhq.com/kernel/v2.4/doc/sysctl/vm.txt.html>
[...]

> From that **v.2.4** page.
>
> Documentation for /proc/sys/vm/* kernel version 2.2.10 <------<<<<
> (c) 1998, 1999, Rik van Riel
>
> Hmmm, so where is the vm.txt for 2.4 online? localhost: /usr/src/linux_2.4/
> only?

http://www.google.com ; enter the text field with

vm.txt linux 2.4

and take your pick. You're really making this much harder than it needs to be.


tony

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----

Floyd Davidson

unread,
Dec 31, 2001, 3:48:45 AM12/31/01
to
Ming He <mi...@hotmail.com> wrote:
>
>[ming@eye /etc]$ free
> total used free shared buffers cached
>Mem: 32356 31704 652 0 684 10376
>-/+ buffers/cache: 20644 11712
>Swap: 146704 11828 134876
>
>
>Let's read this a bit.
>
>32 MB, 650 KB free, 684 KB buffer, (well, forgot what's buffer for, for write to
>disk?), 10 MB cache, 11 MB swap used.
>
>So about 20 MB for loading program.
>
>I did a 'ps' and figure most system startup services already swpped to that 11 MB
>disk.
>
>This 10 MB cache, should include some disk read ahead cache and some cache for swap
>file (don't know about read or write).
>
>I think I'm happy with 4 MB cache. So I can gett 6 MB more memory, for more
>programs to stay in memory.

You already have

652K (free)
684K (buffers)
10,376K (cache)
-----------------------
11,712K ready for more programs

Moving it from buffers or cache to "free" doesn't make it any
more ready for programs! If the kernel wants 10M of RAM for a
program, it just goes right ahead and uses the cache and the
buffer. That just means the next read from disk might be a
little slower if part of it had been in cache and now isn't.
It doesn't slow the kernel down when it loads that new program
though.

>**My question is how to limit the size of cache**.
>
>So if I'm wrong, please explain more on "Linux's habit of using all available RAM
>for cache
>*does not increase paging*". Because I figure that 10 MB is not all that available.

I don't know how you figure it, but if you go look at the source
code or read the docs, you'll learn how to figure it right!

It has absolutely no effect on paging at all.

>This should not be a concern for machines with 128+ MB memory.

It is of far more concern with that amount of memory than it
with only 32Mb. The reason is because with only 32Mb you are in
fact going to be swapping on a regular basis and using all of
your RAM for programs most of the time. That means disk caching
and buffering will not be very effectively used. But on a
machine with enough RAM that it is rarely ever all used for
programs, the system is speeded up considerably by using the RAM
for caching and buffering.

>BTW, I think 2.2.19 manage memory quite more efficient than 2.2.14. And the memory
>RSS reported is same from 'ps' and 'top' now.

Why do you think that?

--
Floyd L. Davidson <http://www.ptialaska.net/~floyd>
Ukpeagvik (Barrow, Alaska) fl...@barrow.com

Tauno Voipio

unread,
Dec 31, 2001, 4:56:47 AM12/31/01
to

"Ming He" <mi...@hotmail.com> wrote in message
news:3C2F980C...@hotmail.com...

Well, this may be a horror story to you.

An executable is not brought into memory in its entire size when starting
the program (exec()). It is only mapped to the process address space. The
pages are read in only when needed (demand paging).

The same applies to files read. They are mapped to memory and the blocks are
read in only when needed.

There is no sense to mess up with the mechanism. You will only lose.

For more information:

Daniel P. Bovet and Marco Cesati, Understanding the Linux Kernel, O'Reilly,
ISBN 0-596-00002-2, chapters 6, 7, 14, 15, 16 and 19.

Ming He

unread,
Dec 31, 2001, 6:02:12 PM12/31/01
to
William Burrow wrote:

> On Mon, 31 Dec 2001 03:51:08 GMT in comp.os.linux.misc,
> Ming He <mi...@hotmail.com> wrote:
> > **My question is how to limit the size of cache**.
>

> Get FreeBSD. Or stop fretting over some numbers you don't know much
> about.

Haha, Bill of New Brunswick, linux is the currently microsoft in open
software. So I think I will stick with linux. And learn it.

dfox

unread,
Dec 31, 2001, 9:45:26 PM12/31/01
to
In article <3C2FE0B3...@hotmail.com>, Ming He wrote:
> Carl Fink wrote:

>> And you are *wrong*. Linux's habit of using all available RAM for cache
>> *does not increase paging*.
>

> I did a 'ps' and figure most system startup services already swpped to that 11 MB
> disk.

Yes, some will swap to disk, given enough uptime, and depending on how
you're using the system. But Carl's comment was about *paging*, not about
swapping. There is a difference. If you load a big enough program, or
have one with significant memory requirements, Linux is perfectly
willing to send little-used services or processes out to disk to make
room for your 'hog'. And, once your 'hog' exits, it may not need to
bring those swapped pages back in - if the process that owns these
pages is sleeping, why bother? It's a waste of disk resources.

This type of thing happens quite a bit on my system, even with 256
megs of RAM (of course, all things being equal, 2.4.x kernels tend
to favor swap more than 2.2.x kernels) if I run a sufficiently
hungry compile or what have you.

If your system is actually spending a lot of time actively paging
to or from disk then you likely need to either add more RAM or
reduce the working set of processes you are running.

0 new messages