Java 性能分析工具-JProfiler


安裝
直接安裝或者在idea插件安裝

GC Roots溯源

  • 代碼
/**
 * @describe: GCRootsTest
 * @author: zhuCw
 * @date: 2020/11/24 18:30
 */
public class GCRootsTest {
    public static void main(String[] args) {
        List<Object> numList = new ArrayList<>();
        Date birth = new Date();

        for (int i = 0; i < 100; i++) {
            numList.add(String.valueOf(i));
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        System.out.println("數據添加完畢,請操作:");
        new Scanner(System.in).next();
        numList = null;
        birth = null;

        System.out.println("numList、birth已置空,請操作:");
        new Scanner(System.in).next();

        System.out.println("結束");
    }
}
  • 使用idea 的jprofile運行該代碼
  • 實時內存-> 所有對象可以查看所有內存的實時情況
  • 視圖->標記當前值 可以查看動態變化
  • 運行GC 可以直接執行GC操作
  • 選中要分析的對象,右鍵 show selection in heap walker
  • 點擊引用
  • 傳入引用 選中對象 右鍵 -> 顯示到GC的路徑進行GC溯源

幫助文檔
https://www.ej-technologies.com/resources/jprofiler/help/doc/main/introduction.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM