• 周四. 10 月 3rd, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

【java_ View the number of instances of the local JVM class and the memory usage in the JVM window

King Wang

1 月 3, 2022

1. export dump file

1.1 obtain PID( Two ways )

You can use the task manager to get
 Insert picture description here
You can also use jconsole Indirect acquisition

  • stay jdk Of bin In the directory jconsole.exe Execution can be
     Insert picture description here
     Insert picture description here

  • If you don’t see the local process 、 There may be a problem with file permissions

    solve :
    First through local java Code runs :
    System.out.println(System.getProperties());
    View the properties java.io.tmpdir=C:\Users%USER%\AppData\Local\Temp
    notes : here %USER% Represents the operating system user name for the variable
    Enter this directory , See a hsperfdata_%USER% Catalog , Enter this directory
     Insert picture description here

1.2 Use jmap export dump file

  • Get into jdk / bin Catalog

jmap -dump:format=b,file=heap.dump <pid>
The current directory will generate heap.dump file

see JVM The number of instances of classes in memory and the amount of memory consumed

  • start-up jvisualvm
     Insert picture description here
  • Import dump file
     Insert picture description here
  • Select file type and file
     Insert picture description here
  • Look at the number of examples 、 size 、 Retain ( Check for memory leaks )
     Insert picture description here
  • PS Reserved fields need to be configured
     Insert picture description here

发表回复