Measuring an application's 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 226847 bytes for the Java heap (accuracy 5%).
### Non-Java heap memory used: 68031 bytes.
###
###                     Worst case allocation overhead:
###     heapSize        dynamic GC      const GC work
###     833k            6               3
###     707k            7               4
###     626k            8               4
###     572k            9               4
###     531k            10              4
###     477k            12              5
###     443k            14              5
###     419k            16              6
###     401k            18              6
###     388k            20              7
###     368k            24              8
###     355k            28              9
###     346k            32              10
###     339k            36              11
###     334k            40              12
###     325k            48              14
###     320k            56              17
###     316k            64              19
###     306k            96              27
###     302k            128             36
###     297k            192             53
###     295k            256             69
###     293k            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.