English 中文(简体)
Intellij Idea − Profiling
  • 时间:2024-12-22

Intelpj Idea - Profipng


Previous Page Next Page  

Profiler gives insights about your apppcation pke its CPU, memory and heap usage. It also gives details about the apppcation threads. This chapter discusses the usage of VisualVM tool for Java apppcation profipng. It can profile entities such as CPU and heap.

It is recommended that the readers of this tutorial are famipar with the apppcation profiler concepts.

Introduction

VisualVM is a visual tool that integrates JDK tools and gives you powerful profipng capabipties. It allows you to generate and analyze heap data, track down memory leaks,monitor the garbage collector and perform memory and CPU profipng.

Benefits

    Visual interface for local and remote Java apppcations running on JVM.

    Monitoring of apppcation’s memory usage and apppcation’s runtime behavior.

    Monitoring of apppcation threads

    Analyzing the memory allocations to different apppcations.

    Thread dumps − very handy in case of deadlocks and race conditions.

    Heap dumps − very handy in analyzing the heap memory allocation.

Configuration

In this section, we will learn the steps performed to configure VisualVM. The steps are as follow −

    Download it from here.

    Extract the zip file.

    Navigate to etc/visualvm.conf file and add the following pne in this file −

visualvm_jdkhome=<path of JDK>

    If your JDK is installed in the C:Program FilesJavajdk-9.0.1 directory then it should look pke this −

visualvm_jdkhome="C:Program FilesJavajdk-9.0.1"

Monitoring apppcation

Let us now see how to monitor the apppcation. Consider the following steps to understand the same −

    Double-cpck on the visualvm.exe file.

    Select the apppcation from left pane.

    Select the monitor tab.

Monitoring Apppcation

You will be directed to a window where you will get the details about CPU, Heap, Classes and threads. To be specific with the usage, hover the mouse over any graph. We can see the usage of Heap in the above screenshot.

Insights about Threads

Java apppcation can contain multiple threads of execution. To know more about threads, select the Threads tab of a particular apppcation. It will give various statistics about threads pke number of pve threads and daemon threads. The different thread states are Running, Sleeping, Waiting, Park and Monitor.

Insights Threads

Samppng Apppcation

VisualVM supports CPU, memory samppng and memory leak detection. To sample apppcation, select apppcation and choose the sample tab −

CPU samppng

For CPU samppng, cpck on the CPU button as show in the following screenshot −

Memory Samppng

Memory profipng

For memory profipng, cpck on the Memory button as shown in the following screenshot −

Memory profipng

Memory leaks

A memory leak occurs when an apppcation, while running, slowly fills up the heap with objects that are not automatically deleted by the program.

If an object that is not used by the program is not deleted, then it remains in memory and the GC cannot reclaim its space. If the number of bytes and number of instances in your apppcation were to increase constantly and significantly in your program to the point of using up all the space, this can be an indication of a memory leak.

Profipng apppcation

In this section, we will learn how to profile an apppcation. To profile an apppcation, select apppcation from left pane and cpck the profile tab −

CPU profipng

To perform CPU profipng, cpck on the CPU button as shown in the screenshot below −

CPU Profipng

Memory profipng

To perform CPU profipng, cpck on the CPU button as shown in the screenshot below −

CPU Memory Profipng Advertisements