How can I access Java heap objects without a reference?

前端 未结 3 1548
你的背包
你的背包 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:13

    I'd look into the the instrument package. Instrument the classes you are interested in so the ctor registers the created instance. You might be able to do this via AspectJ should you not want to use the java.lang.instrument or if the objects are created via something you can control (an IoC container or factories) then you can do something a good chunk less magical.

提交回复
热议问题