[squeak-dev] How to control start-up memory on Windows XP

John M McIntosh johnmci at smalltalkconsulting.com
Fri May 30 18:48:49 UTC 2008


On May 30, 2008, at 10:52 AM, Ramon Leon wrote:

>> That doesn't mean use 200 megs of ram, it means use no more than  
>> 200 megs of
> ram.
>
> Ramon Leon
> http://onsmalltalk.com



For the curious when the VM starts up it allocates space based on the  
image file size plus 100,000.
When it asks the VM platform specific image memory allocation routine  
to allocate this memory then
different things happen.

For unix based VMs (OS-X) we generally use mmap() to allocate a chunk  
of virtual memory.
Now the question is how big? That is set by some sort of startup parm  
which indicates how much.
Before 32bit clean VMs (check your VM) if you allocated a size >= 1GB  
you ran the risk of having
the operating system allocate that memory (for it's own reasons) above  
the 2 GB boundary which
would promptly crash the VM.

With a 32bit clean VM this is not a problem, however historically VM  
might have a 512MB upper limit
to avoid the situation above.


Ok since my image is 50MB what happens on unix systems? Well we  
allocate 512MB of virtual memory then we read
in the 50MB and set the upper soft boundary to about 54MB, the 4MB  
being a growHeadroom memory bound that is
set in the VM. There is a growHeadroom bound (4MB) and shrinkHeadroom  
(8MB) if space free goes below the shrinkHeadroom
we allocate more by moving the bounary,  if space free goes over 8MB  
we lower the boundary.  Thus memory management is
just moving a pointer.  Of course if you run into the 512MB hard  
ceiling you run out of memory.

In some operating systems this might mean asking the operating system  
for more or giving back memory.  I don't claim to
know what Windows does....

Other interesting things here, is some versions of the squeak netscape  
browser plugin which run as subtasks in the browser
would have a memory ceiling set by the HTML where you could specify a  
total amount of memory to use, or memory to use
based on percent or addition to the image size.  This does not apply  
to the current os-x browser plugin btw since it now runs
as a seperate process and feeds display data to the browser.


Measuring

What the tools report are totals for everything, the image is a small  
part, and as you see on Windows it seems to accurately
report what is happening. But on os-x a quick test shows 950MB virtual  
allocated,  but 22.89 mb as private and 29.84 mb as real
The 22.89 private shows the image usage (15 MB image), the 29.84 mb  
that and space for code etc.  Since I"m only asking
for 512MB of virtual who know why os-x thinks 950mb of virtual  is  
what I wanted...  However as a BSD system it doesn't really
allocate that anywhere, it just optimistically implies I might want/ 
get that but that might not be allowed if I actually tried to use it.

--
= 
= 
= 
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
= 
= 
= 
========================================================================





More information about the Squeak-dev mailing list