[PLUG] Re: Question on the "top" command

Anthony Schlemmer aschlemm at attbi.com
Fri Jul 19 02:37:01 UTC 2002


I haven't really spent much time researching the Linux kernel (shame on 
me) but cache is associated with files. System performance can be 
increased quite a bit if data from a file can be accessed from a cache 
in physical memory rather than having to go to the disk and read the 
data. Linux tends to allocate as much memory as it can to filesystem 
cache to improve performance much as possible. It's a balancing act 
since too much memory allocated to cache leaves fewer free pages 
available for user processes.

My guess is that if a malloc() call is made and there is insufficient 
free memory available that the kernel will free up the least recently 
used cache memory pages and make them part of the available "free" 
memory pool to satisfy the malloc() request.

It's pretty amazing to see how much memory Linux can and does allocate 
to filesystem cache. After doing some large compiles I've done some 
large "rm" operations and when files are deleted the associated cache 
memory is freed up. In this scenario I've seen my system go from having 
only a few MB of free memory to several 100MB of free memory.

Tony

On Thursday 18 July 2002 17:58 pm, Mike Witt wrote:
> Mike Witt wrote:
> > On my system (with 256Meg of ram) it starts out with...
>
> S*O*R*R*Y ... This was a most embarrassing typo. The system has
> 128 Meg of memory. The available, used, and free numbers all
> add up. What I was having trouble understanding was that
> when a memory hungry application runs, the free memory goes
> down. But when the application ends, the free memory doesn't
> come back up (it only does that after I re-boot).
>
> What I *think* I'm understanding from the responses
> so far is that the top "free" number doesn't really
> have anything to do with how much memory is available to
> be allocated by a process, but rather how much memory
> has never yet been "touched" for any reason.
>
> So, Anthony Schlemmer suggested "cat /proc/meminfo", which
> does seem to give more information. Is the "Cached" memory
> shown there the memory that is actually available to, say,
> a malloc() call?  Does anyone know?
>
> (I guess that same "cached" number does show up in top, but
> it looked like it was part of the "Swap" information.)
>
> Sorry for the confusion generated by my original typo. Wish
> I'd started reading the responses sooner :-)
>
> -Mike
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug

-- 
Anthony Schlemmer
aschlemm at attbi.com
>>>>This machine was last rebooted:  23 days 22:18 hours ago<<





More information about the PLUG mailing list