Is it possible to 'see' the object graph for garbage collection?

后端 未结 2 1444
傲寒
傲寒 2021-01-06 05:04

I have a Java application that is leaking memory. I know which objects are not being freed during garbage collection, but I can\'t work out what is referencing them.

2条回答
  •  情书的邮戳
    2021-01-06 05:20

    Profilers do this. JProfiler for example. Back in the day I used Optimizeit (which seems to be dead now).

    The conclusion was that listeners were being passed to some collection and not being removed from that collection. The listeners were anonymous inner classes defined on a Frame or a corresponding control class that referenced the Frame, and an anonymous inner class has an implicit reference to its outer class. So that little listener held the whole frame and all its attendant objects in active memory.

提交回复
热议问题