[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: kernel is using 50M of memory



On Thu, Dec 28, 2000 at 03:26:48PM -0500, Josh McKinney wrote:
> On approximately Thu, Dec 28, 2000 at 11:53:42AM -0800, brian moore wrote:
> > On Thu, Dec 28, 2000 at 12:44:27PM -0700, Cameron Matheson wrote:
> > > Hey,
> > > 
> > > I was looking at the memory usage (gmemusage, and /proc/meminfo),
> > > and I was noticing that 'linux' was using nearly 50m of memory.  I
> > > was rather disturbed, and wondering why
> > 
> > Um, /proc/meminfo doesn't say how much the kernel is using (well, not
> > directly, anyway -- you can derive it by subtracting how much RAM is in
> > your system from the 'MemTotal' portion).
> > 
> > Why do you think it's using 50M?  Sure -you- aren't using it?
>
> I is not uncommon for 50M of RAM being used at any particular time,
> especially if you are running X.  The fact that you say the kernel
> is using that much memory is, crazy.  Only Microsoft could do that.

Indeed, which is why I asked him why he thought it was so.

Typically, the kernel takes only a couple or 4 megs.  It would be
seriously broken if it took more than that.  And, again, there's no
direct way to see how much it is using in /proc/meminfo.  I don't have
'gmemusage', so have no idea what it's saying.

[bifur:~] 126 % cat /proc/meminfo 
        total:    used:    free:  shared: buffers:  cached:
Mem:  263925760 247394304 16531456 92672000 64630784 68685824
Swap: 263168000  6881280 256286720
MemTotal:    257740 kB
<snip>

(mmmm..... free memory! yummy!)

>From here, I can, with the knowledge that the machine has 256M of RAM,
figure out the kernel usage:

[bifur:~] 127 % echo '256 * 1024 * 1024 - 263925760' | bc
4509696

Or, I could do:
[bifur:~] 128 % echo '256 * 1024 - 257740' | bc
4404

And see it in K.  Use whichever way you want, depending on whether
bytes or K thrills you.  Either way, on that system it's, more or
less, four and a half megs.  The rest is mine to play with!

(The size here is cause that's a relatively busy machine and has a
healthy dose of RAM, the kernel needs more memory to keep track of more
processes, more buffers, and more memory segments.  With a 386 and 4M,
the kernel doesn't need as much memory because it doesn't have as much to
keep track of.)

Now, if the original poster is concerned because /proc/meminfo (on the
same machine as above) shows something like: 
MemFree:      16144 kB

... then that's a different question, the usual "why is Linux using all
my memory?" one.  The answer is simple... look at what it's using it for:
buffers and cache on the above machine account for well over 128M.  If
I'm not using it for processes, why leave it idle?  Why -not- use it for
buffers and cache, which will make the system faster?

When programs want it, the size of the buffers/cache will drop (I have
some nifty graphs with cricket that graph my memory use -- way cool when
backups run, flushing the cache, and raising the buffers, almost
reversing again when updatedb and logrotate run and flush the buffers and
raise the cache... not exactly -useful- so far, but damn, they're pretty
graphs :)) and the program will get the ram it wants.

That "MemFree:  16144 kB" is just slop.  You want a certain amount
that is -easy- to give to programs (ie, nothing needs to be flushed
first), but not so much that you have memory idle.  On this system, that
usually works out to be 16M that is waiting for something to want it.

-- 
CueCat decoder .signature by Larry Wall:
#!/usr/bin/perl -n
printf "Serial: %s Type: %s Code: %s\n", map { tr/a-zA-Z0-9+-/ -_/; $_ = unpack
'u', chr(32 + length()*3/4) . $_; s/\0+$//; $_ ^= "C" x length; } /\.([^.]+)/g; 



Reply to: