Java Application Performance and Memory Management

The higher lever of compilation, the most optimised will be your code.

-XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation: See compilation details in file with more details.

-XX:+PrintCodeCache: See the size of the code cache. Change the code cache: -XX:InitialCodeCacheSize -XX:ReservedCodeCacheSize -XX:CodeCacheExpansionSize

-XX:CompileThreshold: num of threads to use for native compilation -XX:CompileThreshold: num of times that a method needs to be invoked before the code is cached.

32 bit vs 64 bit

If app needs more than 4GB and using many long or double types, use 64 bit.

What is the -client flag? More flags: -server or -d64

Useful commands

get all running java comands and [ID]s.

get the flag value of a running java process.

Memory

There are three sections:

Memory Leaks

The standard definition of a memory leak is a scenario that occurs when objects are no longer being used by the application, but the Garbage Collector is unable to remove them from working memory – because they’re still being referenced. As a result, the application consumes more and more resources – which eventually leads to a fatal OutOfMemoryError.

Generate Heap Dump

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=somepath 

JVM Tuning - Flags

String pool tuning

Garbage Collection