JamaicaVM -- User Documentation: The Virtual Machine for Real-time and Embedded Systems | ||
---|---|---|
Prev | Chapter 3. Configuration of the Memory Management | Next |
In addition to the measure memory requirement of the application, a small table of possible heap sizes and corresponding worst-case allocation overheads is printed. The worst case allocation overhead is given in units of garbage-collection work that are needed to allocate one block of memory (typically 32 bytes). A unit of garbage-collection work can be performed in a platform dependent amount of time. On the PowerPC processor, a unit correspond to execution of about 160 machine instructions.
From the printed table, we can now chose the minimum heap size that corresponds to the desired worst-case execution time for the allocation of one block of memory. A heap size of 373k corresponds to a worst-case of 7 unit of garbage-collection work (1120 machine instructions on the PowerPC) per allocation of one block, while a smaller heap size of, e.g., 239k can only guarantee a worst-case of 40 units of garbage-collection (6400 PowerPC- instructions) work per allocation.
If we find that for our application 14 units of garbage-collection work per allocation is sufficient to satisfy all real-time requirements, we can build the final application using a heap of 538k:
> jamaica -heapSize 538k -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 > |
The resulting application now runs with the minimal amount of memory that guarantees the selected worst-case execution time for memory allocation. The actual amount of garbage collection work that is performed is determined dynamically depending on the current state of the application (its memory usage etc.) and will in most cases be significantly lower than the described worst-case behaviour, so that in average an allocation is significantly cheaper than the worst-case allocation cost.