[comp.sys.mips] Where does the memory go - I forget ...

tonyr@tekadg.ADG.TEK.COM (Tony Rick) (08/03/90)

Fellow MIPSians,

     My question is: Where does the memory go?

     The reason I ask this is that we run some large processes, 
whose sizes are reported by ps to be >5000 pages.  When one of these 
runs, uncontested, the system response goes way down, vsar show much 
swapping and paging, and very few freemem pages available, <250.  

     I have an m120-5 with 32Mbyte memory.  At boot time the console
eventually says "Available memory = 30367744" which I take to mean
a byte count of memory left after the OS has claimed it share.  I also
think 32Mbyte means 1024*1024*32=33554432 bytes.  So my simple
arithmetic skills tell me that the OS has 3186688 bytes(778 pages).  
A 'ps -el' snapshot shows 27 processes with a total of 909 pages or clicks 
(what is a 'click'?).  Now some of these processes report less than 25 (pages 
or clicks), and there is a tuneable kernel parameter MINARMEM, default
value 25, that specifies a minimum number of text and data pages
reserved for a user process.  Taking that into account, as a worst case
estimate in my search for memory, I can say that the total number of
pages accounted for by that 'ps -el' snapshot is 1053.  Now a 'vsar -r'
snapshot says that there are 4508 pages (freemem) available for user processes.
All of this information gathering happenned right after boot before any
major accumulation of operating history, well, not more than about 5
minutes.

Hmm...

That's        8192 pages total in the system, (pagesize = 4096),
	778        pages occupied by OS
       1053        pages occupied by user processes
       4508        pages of freemem
       -------------
       6369        pages in use accounted for
	      1823 pages unacccounted for (7467008 bytes)

That is a considerable amount of the memory.

When we first got the machine, it had 24Mbyte (3 memory boards).  I
added one more later ( we had the 'self service' type of support then ).
Did I miss something when I put the new board in?  Did I miss something
in searching for memory?  What's happenning?  Where does the memory go?
Help, Mister Wizard!

tony rick
Tektronix, Inc.  Beaverton, OR
email:tonyr@tekadg.adg.tek.com
voice:503-627-2942

wje@redwood.mips.com (William J. Earl) (08/08/90)

In article <871@tekadg.ADG.TEK.COM>, tonyr@tekadg (Tony Rick) writes:
>      My question is: Where does the memory go?
> 
>      The reason I ask this is that we run some large processes, 
> whose sizes are reported by ps to be >5000 pages.  When one of these 
> runs, uncontested, the system response goes way down, vsar show much 
> swapping and paging, and very few freemem pages available, <250.  
> 
>      I have an m120-5 with 32Mbyte memory.  At boot time the console
> eventually says "Available memory = 30367744" which I take to mean
> a byte count of memory left after the OS has claimed it share.  I also
> think 32Mbyte means 1024*1024*32=33554432 bytes.  So my simple
> arithmetic skills tell me that the OS has 3186688 bytes(778 pages).  
> A 'ps -el' snapshot shows 27 processes with a total of 909 pages or clicks 
> (what is a 'click'?).  Now some of these processes report less than 25 (pages 
> or clicks), and there is a tuneable kernel parameter MINARMEM, default
> value 25, that specifies a minimum number of text and data pages
> reserved for a user process.  Taking that into account, as a worst case
> estimate in my search for memory, I can say that the total number of
> pages accounted for by that 'ps -el' snapshot is 1053.  Now a 'vsar -r'
> snapshot says that there are 4508 pages (freemem) available for user processes.
> All of this information gathering happenned right after boot before any
> major accumulation of operating history, well, not more than about 5
> minutes.
> 
> Hmm...
> 
> That's        8192 pages total in the system, (pagesize = 4096),
> 	778        pages occupied by OS
>        1053        pages occupied by user processes
>        4508        pages of freemem
>        -------------
>        6369        pages in use accounted for
> 	      1823 pages unacccounted for (7467008 bytes)
> 
> That is a considerable amount of the memory.
> 
> When we first got the machine, it had 24Mbyte (3 memory boards).  I
> added one more later ( we had the 'self service' type of support then ).
> Did I miss something when I put the new board in?  Did I miss something
> in searching for memory?  What's happenning?  Where does the memory go?

      There are several parts to the answer.  First, "available
memory" does not include memory which may later be added to the disk
buffer pool, and does include memory which may later be subtracted
from the disk buffer pool.  The disk buffer pool can grow when file
I/O load is high, and shrink when virtual memory load is high.

     Second, the kernel allocates additional pages to represent
processes and other structures.  Each process in RISC/os 4.0 requires
a minimum of 4 pages which are not counted toward the "SZ" total in
ps.  On the other hand, the "SZ" values are somewhat inflated, since
they include text pages, so that text pages are counted multiple times
if you take the sum of the "SZ" values.

     Third, MINARMEM is the minimum number of resident pages (pages
which may not be swapped); new resident pages may not be allocated 
if availrmem is below MINARMEM.  In general, availrmem rarely goes
anywhere near as low as MINARMEM.

     Fourth, when total virtual memory exceeds physical memory, freemem
generally stays at a low level (about 100 to 200 pages), since the system
avoids doing more paging than necessary.  (This is not the case
above, since you have quite bit of free memory.)

     Given that you have a lot of free memory, the disk buffer cache
has probably grown substantially.  Since you started out with about
30 Mb of available memory, your boards are probably correctly configured.

-- 
	William J. Earl			wje@mips.com
	MIPS Computer Systems		408-524-8172
	930 Arques Avenue
	Sunnyvale, CA 94086