Subject: Re: memory allocation question
To: Tim Underwood <TimU@hightouchinc.com>
From: Noriyuki Soda <soda@sra.co.jp>
List: port-hpcmips
Date: 08/12/2004 02:10:13
>>>>> On Wed, 11 Aug 2004 11:41:22 -0500,
	"Tim Underwood" <TimU@hightouchinc.com> said:

> When in text mode, I run "top", and a line is displayed that shows:

> Memory: 11M Act, 132K Wired, 3012K Exec, 6676K File, 13M Free
> Swap: 257M Total, 257M Free

> Not sure what "Wired" means.

"Wired" is memory region which is locked on physical memory.

> 1.  How can I reduce the approx 6MB memory given over to disk cache?  In
> Linux, I just echo a value out to the /proc subsystem, and it happens
> dynamically.  Is NetBSD like the "old" unices, where I have to set a
> value and recompile the kernel?  Or is there a dynamic way of setting
> this?

You can tweak the file cache usage dynamically by setting sysctl
variables. I recommend the following values for systems which only
have 32MB memory, and for interactive use.
	$ sysctl -w vm.filemin=2
	$ sysctl -w vm.filemax=4
(default value is vm.filemin=10 and vm.filemax=50)
You can use /etc/sysctl.conf to set these values at boot time.

But this setting affects only when free memory isn't enough.
File cache grows as far as there is enough free memory.
If memory shortage happens, and if Exec pages or Anon page need
more memory, File pages will be reclaimed and the pages will be
used for Exec pages or Anon pages.

i.e. Because the above "top" result shows there is enough free memory,
the sysctl variables won't affect at that state.

Our "top" doesn't show the usage of Anon memory, but you can see
the size in "anonymous pages" field of the output of "vmstat -s"
command (the unit is not bytes, but page size).

basically,
	Total_memory_for_userland
    ~=  Active_memory + Inactive_memory + Wired_memory + Free_memory
    ~=  Anonymous_memory + cached_Executable_memory + cached_File_memory

Although this formula isn't so accurate because there is other use...
--
soda