[clean-list] Next Heap Size Factor ?

John van Groningen johnvg@cs.kun.nl
Tue, 21 Nov 2000 16:48:45 +0000


>Could somebody explain the exact meaning of the "NextHeap Size Factor"
>parameter of the project options of the Clean 2.0 IDE ?
>
>It is said in the IDE manual that "If a garbage collection does not free
>enough memory, the heap is expanded (with the factor Next Heap Size Factor)
>up to a maximum (the Maximum Heap Size)."
>
>It is not clear to me what this exactly means, and how that parameter can
>impact the run-time characteristics of the programs.

When a Clean program starts, it allocates a heap of "Maximum Heap Size" bytes,
but initially only uses "Initial Heap Size" bytes. When this initial size has
been used (or half of it when you use the copying collector), the garbage
collector is invoked.

When the garbage collector finishes, the amount of heap that is still in use
is multiplied by the "Next Heap Size Factor" (or half of it for the copying
collector). This heap will then grow or shrink to this amount of memory,
and the garbage collector will be invoked again when this memory has been
used. If this amount is larger than "Maximum Heap Size", the heap only grows
to this maximum size.

So after each garbage collection we use the "Next Heap Size" factor to
compute the size of the heap until the next garbage collection.

If you use a small "Heap Size Factor" your program will use less memory and
have fewer cache misses. However the garbage collection will be invoked
more often and so garbage collection will use more time.

The opposite happens if you use a large "Heap Size Factor": the program uses
more memory, has more cache misses (or even page misses), but garbage
collections will happen less often and garbage collection will use
less time.

Regards,

John van Groningen