How can I access Java heap objects without a reference?

前端 未结 3 1585
你的背包
你的背包 2021-01-06 12:37

I would like to get a reference to all objects in the Java heap, even if I don\'t immediately have a reference to those objects in my active thread. I don\'t need non-refere

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-06 13:12

    If you want to take a heap dump programmatically, you'll not find suitable APIs in the java.* or javax.* namespace. However, the Sun runtime comes with the HotSpotDiagnosticMXBean which will enable you to take a heap dump by writing the contents of the heap on to a specified file in disk.

提交回复
热议问题