some not-so-random questions

Markus Kohler markus_kohler at bbn.hp.com
Wed Nov 4 10:21:35 UTC 1998


Tim Rowledge wrote:
> 
> On Tue 03 Nov, Andreas Raab wrote:
> > Ian,
> >
> > > On Unix there is a -memory option that takes a memory size
> > > (in bytes) as argument (with optional 'k' or 'm' suffix to avoid typing lots
> > > of zeroes).  There is also an environment variable "SQUEAK_MEMORY" that you
> > > can set, the existence of which implies the -memory option (I leave this
> > > permanently set to "10m", and I've never run out of memory in Squeak ;-).
> >
> > How the heck do you manage this?!?! I'm usually run Squeak with at least
> > 32MB memory - that's my way not to run out of memory too early. Well,
> > perhaps you've never imported a large JPEG image in 32bit Morphic?!
> Acorn Squeak runs perfectly happily with -memory:5m  unless you want to
> generate new VM when 8m is more useful. Obviously the Windows bloat virus has
> found a way to infect your VM Andreas!
> 
> Expanding the memory allocation for Squeak should not be too difficult in most
> cases. For Unix, sbrk() ought to work. 

I discussed that idea with Andreas in more detail and we found that it's
not as
easy as I first thought. The main problem is that system calls might
allocate
memory with malloc and that conflicts with  using sbrk. 

> For Acorn, resizing the dynamic area is
> trivial.  I _think_ Mac's finally got some way to expand memory a while ago.
> Windows? Hmm, how about actually allocating a huge virtual space but pretending
> to the VM that you only have as much as the -memory param asked for. 

Yesterday I did a quick hack on Unix (HP-UX) to use mmap instead of
allocating memory
by malloc. It seems to work very well. I can start squeak with 300 MByte
and
it comes up very quickly. What's interesting is that "top" shows only
the Megabytes
actually used. So mmap seems to use a "lazy" mechanism  on HP-UX. 

One problem is that it actually core dumps when I specify 400Mbyte. I
need to check
what the reason is. Maybe that's because there's not enough paging space
on my machine.  

> Then to
> expand, you just change that 'fake' boundary. The only trick that springs to
> mind is remembering to reset the size of the free chunk at the top of memory.
> 
> Shrinking object space wouldn't be much harder from the VM point of view,
> though I'm not sure whether the released memory would get back to the OS pool
> very efectively.

Yes, I've never seen an application on unix that does that. Visualworks
for example
doesn't do it too. 

> 
> The real problem with both expansion and shrinking is the policy decision of
> when to do it. VW has quite a complicated policy implemented in the image, with
> hooks to change it almost any way you want. IIRC almost no customer ever
> changed anything, they just complained that the default wasn't good enough for
> them!

We did extensively !
I was working on a multithreaded server for network and system
management. 
One problem was that Visualworks was always growing. 

If someone wants to try out  mmap0squeak. Basically you have only to use
mmap(0, desiredHeapSize, PROT_READ|PROT_WRITE,
       MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
instead of 
malloc(desiredHeapSize)

in sq.h

Some Unixes may not support the MAP_ANONYMOUS option. I've seen that
on some Unixes it can be replaced by mapping /dev/zero. 

Markus

-- 
Markus Kohler  mailto:markus_kohler at hp.com





More information about the Squeak-dev mailing list