To profile and optimize memory use, the typical workflow is to run your app and do the following:
- Profile the app using the Memory Monitor to find out whether undesirable garbage collection event patterns might be causing performance problems.
- If you see many garbage collection events in a short amount of time, dump the Java heap to identify candidate object types that get or stay allocated unexpectedly or unnecessarily.
- Start allocation tracking to determine where any problems are happening in your code.
The Java heap data shows in real-time what types of objects your application has allocated, how many, and their sizes on the heap. Viewing the heap helps you to:
- Get a sense of how your app allocates and frees memory.
- Identify memory leaks.
Allocation tracking records app memory allocations and lists all allocations for the profiling cycle, including the call stack, size, and allocating code. It helps you to:
- Identify where many similar object types, from roughly the same call stack, are allocated and deallocated over a very short period of time.
- Find the places in your code that may contribute to inefficient memory use.