[Vm-dev] Where is the heap?

Javier Pimás elpochodelagente at gmail.com
Wed May 12 05:54:40 UTC 2010

Well well well, this is nice, now I'm getting more into this. Thanks all for
the quick answers! The iSqueak wiki (which I had seen before but thought it
only had info about iPhone) helped a lot.

Here are some concepts I got (hope they are right)

The heap is at a virtual address that depends on the platform. Many
platforms try to put it starting at a fixed virtual address (like 500M or
512M). Unix doesn't bother.

The use of /dev/null mapping in unix is not that important because of mmap's
MAP_PRIVATE flag, which makes a copy of the mapped object after first write.
In mac it uses the image file instead and MAP_SHARED, which may actually
change the image file on memory writes. So in that case I wonder why it
doesn't happen (or it does?), maybe because the file is closed after

After loading, as oops are virtual memory addressed, they are iterated (in
case the heap isn't loaded in a fixed position, ie. unix) and adjusted to
the new heap start.

Also -this confused me a bit-, in some platforms you mmap a heap of size
much bigger than image size, like 512MB (this was what puzzled me, I
confused it with memory address offset). In the end you get 512MB mapped at
offset 500M, of which the OS only reserves the used part. In the space
between 0 and 500M lies the VM, stack globals and other stuff.

Excelent, now for SqueakNOS we may use the total amount of available memory,
as Bert said, but we have to be carefull: Saving the image requires disk
access, which is now done by a beautiful disk driver written in smalltalk
(no file-write primitives). Our idea then is that inside primitiveSnapshot
we make the snapshot go temporarily to a byte array instead of disk, and
after resuming the interpreter we send the order to write to disk. As you
can imagine, this has the drawback of requiring double of image size be
reserved in memory among other things, but should work. We are open to more
elegant ideas, of course!

As for heap mem allocating have a look at what we have now in squeaknos...

sqInt sqGrowMemoryBy(sqInt oldLimit, sqInt delta)    {
       // XXX: We should check available memory here.
    return oldLimit+delta;


On Tue, May 11, 2010 at 9:10 PM, Igor Stasenko <siguctua at gmail.com> wrote:

> On 12 May 2010 01:58, Bert Freudenberg <bert at freudenbergs.de> wrote:
> >
> > Am 11.05.2010 um 15:50 schrieb John M McIntosh:
> >> So as Bert said malloc() is the simplest solution...
> >
> > I actually didn't mention malloc(). Since in SqueakNOS there *is* no
> operating system, I'd have thought you don't even need to malloc().
> >
> Yeah, i think SqueakNOS  could simply declare an appropriate address
> space range as its own, and just use it :)
> > - Bert -
> >
> >
> >
> --
> Best regards,
> Igor Stasenko AKA sig.

Javier Pimás
Ciudad de Buenos Aires
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100512/95169723/attachment-0001.htm

More information about the Vm-dev mailing list