[Vm-dev] Where is the heap?
Javier Pimás
elpochodelagente at gmail.com
Tue May 11 22:15:10 UTC 2010
Hi,
I'm working in memory management of SqueakNOS platform. Currently we
use a static size heap, and we'll probably have to change that. I read in
the blue book that the heap is implemented as a *contiguous* chunk of
memory, is the heap done that way in squeak?
I looked how it's implemented in unix and saw that sqAllocateMemory
uses mmap. I don't have experience with this function, but I wonder if it
means that the heap is allocated in a virtual contiguous chunk that gets
mapped to some place in disk. Or maybe it just reserves contiguous virtual
addresses that are in different blocks of real memory?
The alloc line is this, (sqUnixMemory.c)
if (MAP_FAILED == (heap= mmap(0, heapLimit, MAP_PROT, MAP_FLAGS, devZero,
0)))
Also, other question is what is this mapping to /dev/zero? Then
reading from the heap wouldn't return allways zero? Is it because this mmap
isn't actually backed by any file? Does mmap reserve heapLimit bytes in real
memory? I mean, if you write to the mapped address, you write to real
memory, device memory, or both?
Lastly, growing the heap gets to this:
if (MAP_FAILED == mmap(base, newDelta, MAP_PROT, MAP_FLAGS | MAP_FIXED,
devZero, heapSize))
which doesn't alter heap start, so it has to be that when resizing the heap
the only thing that happens is that some memory is reserved and mapped to
the ending address of it.
Well as you can see I'm rather confused so any help is wellcome, thanks for
reading.
Javier.
--
Javier Pimás
Ciudad de Buenos Aires
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100511/0ff12bee/attachment.htm
More information about the Vm-dev
mailing list