Static Garbage Collection Work

For applications that require best worst-case execution times, while average case execution time is less important, Jamaica also provides to statically select the amount of garbage collection work. This forces the given amount of garbage collection work to be performed at any allocation, not regarding the current state of the application. The advantage of the static mode is that worst-case execution times are lower than using dynamic determination of garbage collection work. The disadvantage is that any allocation requires this worst-case amount of garbage collection work.

The output generated by the application that was built using the option -analyse also shows possible values for the static garbage collection work. In the example above, the static garbage collection work varies from 3 to 80 units for heap sizes between 535k and 215k bytes. A unit of garbage collection work is the same as in the dynamic case, ie. about 160 machine instructions on the PowerPC processor.

Similarly if we want to give the same guaratee of 14 units of work for the worst-case execution time of the allocation of a block of memory, a heap size of 386k bytes is sufficient. To inform the builder that static mode should be used, the option -staticGC and the number of units of work have to be specified when building the application:

> jamaica -heapSize 386k -staticGC 14 -smart -numThreads 2 HelloWorld
 + HelloWorld.c
 + HelloWorld.makefile
Classfile compaction gain: 54.217335% (100324 ==> 45931)
gcc -o HelloWorld.o -c HelloWorld.c -I /Jamaica/Target/include/
 -I /Jamaica/JamaicaVM/include/ -I /Jamaica/JamaicaGC/include/
gcc -o HelloWorld HelloWorld.o /Jamaica/obj/jamaica_vm.o
 /Jamaica/obj/jamaica_gc.o /Jamaica/obj/classes.o
 /Jamaica/obj/interpreter.o /Jamaica/obj/nativecode.o
 /Jamaica/obj/jamaica_threads.o /Jamaica/obj/jamaica_thread.o
 -lm -lpthread
strip HelloWorld
>