Dynamic system memory use

Tim Rowledge tim at sumeru.stanford.edu
Fri Feb 1 22:03:40 UTC 2002


Lex Spoon wrote:
>> >     #define sqGrowMemoryBy(oldLimit, delta) oldLimit
> >     #define sqShrinkMemoryBy(oldLimit, delta) oldLimit
> >     #define sqMemoryExtraBytesLeft(includingSwap) 0
> > in sq.h and their uses.
> 
> Unfortunately, these functions are hard to implement.  They expect the
> heap to be reallocated *in place*, and more importantly, they expect the
> heap to stay as one contiguous segment.  realloc() could probably be
> made to work, but it's still going to be difficult on the underlying OS,
> simply because realloc-ing hundreds of megs will make the 4 gigs of
> 32-bit addressable space start running out!
Yup, requiring a single contiguous space creates its own difficulties,
but believe me, multiple segments have their own delights.


> > One of the classic problems with trying to extend or reduce memory usage
> > is thrashing; you do all the work of getting more or releasing some and
> > - wham, you need to reverse and do the opposite. I did a version once
> > that tried a hysterisis approach of never releasing more than one
> > previously added segment jst in case and that worked quite well in the
> > seriously memory constrained environment in which it lived (1Mb ram
> > total on the machine).
> 
> Was this work for Squeak?!
Nope; it was a system built from Eliot's BrouHaHa vm for the 'Active
Book' way back in 89-91.

> 
> A segmented allocater would be a lot easier on the underlying platform.
> Every platform has malloc() and free().  Not every platform has
> "allocate and leave plenty of space after the end()" and "remember that
> area I allocated?  allocate some more() ".
Quite true - at least I've never yet developed on a platform that didn't
at least _pretend_ to do malloc.

One nice thing about the Acorn is that the OS manipulates the memory
paging tables to allow extension of memory areas without needing to do
anything like realloc; it sort of works in with the odd way they provide
each process a memory map that looks like it is the only process. I
think they even extended it sometime to allow processes to share some
kind of memory areas.

tim





More information about the Squeak-dev mailing list