Comparing dynamic mode and constant garbage collection work

The choice between dynamic mode and constant garbage collection work strongly depends on the kind of application. If worst-case execution time and low jitter are the most important criteria, constant garbage collection work will provide the better performance with smaller heap sizes. But if average case execution time is also an issue, dynamic mode will typically give better overall throughput, even though for equal heap size the guaranteed worst-case execution time is longer than with constant garbage collection workk.

Another point that might be important is gradual degradation. Dynamic mode and constant garbage collection work differ significantly for the case that the application does not stay within its memory bounds that were fixed when the application was build.

The reasons for an application using more memory might be as follows:

Whatever the reason, in some environments it might be of importance to know the behaviour of the memory management in the case the application exceeds the assumed heap usage.

In dynamic mode, the worst-case execution time for an allocation cannot be guaranteed anymore as soon as the application uses more memory. But as long as the excess heap used stays small, the worst-case execution time will increase only slightly. This means that the original worst-case execution time might not be exceeded at all or might be exceeded by a small amount of time only. But the garbage collector will still work properly and recycle enough memory to keep the application running.

If constant garbage collection work was chosen, the amount of garbage-collection work is not increased even if the application uses more memory than originally anticipated. This means, allocations will still give the same worst-case exection time guarantees. Instead, the collector cannot give a guarantee that it will recycle memory fast enough. This means, the application might abruptly fail with an out-of-memory error. Static mode does not provide graceful degradation of performance in this case, but might cause abrupt failure even if the application only slightly exceeds the expected memory requirements.