Measuring an applications memory requirements

The build process is performed exactly as it would be without the -analyse option, the only difference is that the garbage collector is instructed to measure the application's memory usage with the given accuracy. The result of this measurement is printed to the console after execution of the application:

> ./HelloWorld
              Hello        World!
           Hello       World!
        Hello     World!
     Hello    World!
   Hello   World!
 Hello  World!
Hello World!
Hello World!
Hello World!
Hello World!
 Hello  World!
   Hello   World!
     Hello    World!
        Hello     World!
           Hello       World!
              Hello        World!
                 Hello         World!
...

### Application used at most 294372 bytes for the Java heap (accuracy 5%).
### Non-Java heap memory used: 51102 bytes.
###
###                     Worst case allocation overhead:
###     heapSize        dynamic GC      static GC
###     1045k           6               3
###     881k            7               4
###     776k            8               4
###     705k            9               4
###     653k            10              4
###     583k            12              5
###     538k            14              5
###     507k            16              6
###     484k            18              6
###     466k            20              7
###     442k            24              8
###     425k            28              9
###     413k            32              10
###     404k            36              11
###     396k            40              12
###     386k            48              14
###     379k            56              17
###     373k            64              19
###     361k            96              27
###     355k            128             36
###     349k            192             53
###     346k            256             69
###     344k            384             100

In this example, the application used at most 263921 bytes of memory. The accuracy of 5% indicates that the actual memory usage of the application might be up to 5% less than the measured value, but not higher. JamaicaVM uses the Java heap to store all dynamic data structures internal to the virtual machine (as Java stacks, classes, etc.), this explains the relatively high memory demand for this small application. A small and fixed amount of memory (1781 bytes in this case) is needed in addition to the Java heap.