我一直在寻找我的应用程序中的内存泄漏,并发现由于某种原因枚举实例保留在堆中。
为了模拟它,我在 tomcat 中部署了我的应用程序,对其进行了一些处理,停止了它并在 tomcat 上执行了 GC(通过 jconsole)。然后拿了一个堆转储,发现了这个:
instance of x.mgbean.quote.Input$Tab@0xe0887c0 (16 bytes)
Class:
class x.mgbean.quote.Input$Tab
Instance data members:
name (L) : VEHICLE (24 bytes)
ordinal (I) : 0
References to this object:
java.util.HashMap$Entry@0xe15f7c0 (24 bytes) : field value
class x.mgbean.quote.Input$Tab (84 bytes) : static field VEHICLE
[Lx.mgbean.quote.Input$Tab;@0xe0887f0 (20 bytes) : Element 0 of [Lx.mgbean.quote.Input$Tab;@0xe0887f0
[Lx.mgbean.quote.Input$Tab;@0xe1541e8 (20 bytes) : Element 0 of [Lx.mgbean.quote.Input$Tab;@0xe1541e8
知道这怎么会发生吗?