growing and shrinking ObjectMemory

Lex Spoon lex at cc.gatech.edu
Sat Mar 3 02:11:50 UTC 2001


Bert Freudenberg <bert at isg.cs.uni-magdeburg.de> wrote:
> On Fri, 2 Mar 2001, Lex Spoon wrote:
> 
> > Anyway, after a little thought, I came up with the below code which can
> > release memory that's no longer used.  The trick used is to munmap()
> > unusued portions and then to mmap() them back again in order that the
> > region of memory stays contiguous.
> 
> Looks better already :)
> 
> Still, you're mmapping the entire MEMORY_TO_USE while I think it would
> suffice to just mmap what was asked for.
> 

Actually, I think such a big chunk needs to be allocated, in order to
assure that the ObjectMemory can grow when requested.  If only the
minimal amount is allocated, then two problems can come up:

	1. The region could be mapped at the *end* of the usable address space,
so there won't be any room to grow.
	
	2. Some other code in the VM, eg the malloc() library, could call
mmap() and take over the address space just following our own.


I don't know a good solution to these problems other than to allocate a
big chunk up front.  Well...  it would be neat if the Squeak allocator
could deal with non-contiguous chunks of memory.  But that's
complicated....


-Lex





More information about the Squeak-dev mailing list