how is memory allocated

lex at cc.gatech.edu lex at cc.gatech.edu
Tue Oct 12 20:47:09 UTC 2004


Kamil Kukura <kamk at volny.cz> wrote:
> This is rather dumb question. If I have image of size, say 20MB, is it 
> loaded into the memory as one big chunk? Or is memory allocated on 
> demand somehow? This concerns me because I have virtual servers with 
> only 24MB RAM and they run Linux Debian with Apache with PHP and still 
> have free memory.


Here are some more details.

The size of Squeak's heap will initially be the size of the image plus a
little operating room past that.  After that, it will additionally use
whatever memory your server allocates.  The used memory is in one
sequential chunk of *virtual* memory, but being virtual memory, this can
be located anywhere in RAM or in swap.

Squeak won't demand page out of its image file.  Instead, when you load
an image to begin with, Squeak goes through the entire heap a few times
to fix up some various things.  Thus, starting a large Squeak image
(relative to available RAM) will probably cause a little thrashing. 
After that, a lot of the memory will likely drift out of RAM and into
swap.

If you avoid full garbage collects, then Squeak's virtual memory will
act a lot like a C program's.  The used spots will stay in RAM, and the
unusued spots will quietly page out to disk.

If you do end up with a full garbage collect, Squeak will page through
the whole heap again, causing thrashing just like when you first start
the package only a little worse (worse, because the traversal will be in
the order of the object pointers, not necessarily sequentially through
the heap).

Most servers are unlikely to do a lot of full GC's, though there is
always the risk.  If you are running into full GC's, though, you could
play with the VM parameters on memory allocation.

	http://minnow.cc.gatech.edu/squeak/3710

-Lex

PS -- 20 MB sounds very large for a server image.  You might consider
starting from a mini image of some sort, if memory is an issue.



More information about the Squeak-dev mailing list