[Oberon] Ram & processors

Patrik Reali reali at acm.org
Sun Feb 2 16:50:11 CET 2003


> From: "Gérard Meunier"
> In fact, I want to estimate which amount of memory I can allocate on the
> heap without disturbing too much other applications. Which is the most
> pertinent "free" value for starting calculus? The value from your
FreeMemory
> procedure or the value from GetHeapInfo? Is the memory in "low" and "high"
> parameters allocatable? I suppose it's reserved for the stack, isn't it?


AosHeap.GetHeapInfo(total, free, largest);

largest gives you the currently largest allocable block in memory (due to
fragmentation this is less than the total free heap memory). It is usually
possible to allocate more, because the memory manager can start a garbage
collection to reclaim unused memory blocks, and in case of need it can also
add memory pages to the heap.

The number of free pages can be asked with AosMemory.GetFreeK. This pages
are used for stacks and heap. Stack pages can be reclaimed, whereas heap
pages are allocated "forever". If you run many active object you should be
careful not to overallocate, otherwise you may run out of pages for the
stacks. This is rare but may happen (I experienced this when running some
big benchmarks on the JVM and afterwards compiling with Paco).

The details about page allocation (and some restrictions like the maximum
number of memory pages used for the heap) can be found in Pieter Muller's
thesis (page 65, Interaction with the page heap).

-Patrik




More information about the Oberon mailing list