[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: P-Source: A Guide to the Apple Pascal System
On Nov 29, 2:54 am, mdj <mdj....@gmail.com> wrote:
> Yeah. I'm interested to see how you manage the heap - with so little
> space it could potentially thrash really badly. The p-system got
> around this problem by 'disposing' the dispose procedure and simply
> having a stack instead, but for Java that's not an option.
NanoVM combines the stack and heap management in a way that allows for
a sliding boundary between the two. This seems obvious to C
programmers, but many OOP compiler writers used fixed size stack and
heap regions. A sliding boundary lets the heap breathe a little
between collections. The routine that allocates stack space can force
a garbage collection if it doesn't have enough room on the stack.
Likewise, the heap allocator can force a collection if it needs more
space.
The trick is to avoid abritrary to timed collections. You only collect
when you must collect. It will still thrash somewhat, of course.
This is the "pay me now or pay me later" debate. A heavier allocator
is slow but it saves on CPU cycles needed for collections. The trick
is to find the optimum tradeoff. On a small machine I think you need
more smarts in the allocator. Traditional JVM and .NET CLRs opt for
faster allocators and timed background collectors that tend to be
heavy.
Eric