Introduction to profiling
Profiling is a type of runtime analysis that operates on large amounts of runtime data and gives you a birds-eye view of what is happening inside a process. The collected data relates to various aspects of program operation, such as CPU usage, memory allocation, and threads' activity.
Profiling can be instantaneous, like capturing a memory snapshot, or long-running. For example, the CPU profiler can collect data during arbitrarily large periods of time, like hours or even days of program operation.
When is profiling helpful?
Profiling tools help you:
Identify bugs, bottlenecks and diagnose poor performance
Identify hot spots and opportunities for optimization (not necessarily related to a performance problem)
Assess or compare the performance of different solutions
Get a better understanding of how a program operates under the hood
Supported profiling types
IntelliJ IDEA profiler is not a single tool but rather a suite of related tools. They all have their own area of application:
CPU and memory live charts – allow you to monitor a process in real time. This type of diagnostics gives you the resource consumption metrics over time and may be useful as a monitoring tool or, in the case of a performance problem, a starting point for further investigation.
CPU and allocation profiling – allow you to see how CPU and memory resources were utilized during a particular period of time. This may be useful for detecting hot code, opportunities for optimization, or just discovering how a program operates at runtime.
Memory snapshots – allow you to analyze how memory is used at a particular instant. This data is useful for investigating memory-related issues.
Thread dumps - allow you to see the program state at a particular instant. The produced data captures the state of all threads. This may be useful, for example, to examine an unresponsive application.