jni jvm 内存泄漏,如何识别JNI全局引用内存泄漏的原因?

I'm using Tomcat and after stopping my web application there's still a reference to the classloader instance of my web application.

With the consequence that a notable amount of memory (mostly related to static data) will not be freed. Sooner or later this results in an OutOfMemoryError.

I took a heap dump and I realized that its held by a prevents that the classloader will be

My application does not use JNI. I am also not using the Apache Tomcat Native Library. I am using a Sun/Oracle JDK.

I'd like to track down the cause/origin of this global reference.

(My guess is that the JVM internally references the classloader - but why/where?).

Question:

Which approaches/toolsets exists to achieve this?

UPDATE

It seems that bestsss is right and the JNI global references has been introduced by the jvm debug mode. This helped me out but it does not answer the question so I am still curious to get an answer to the question which might be helpful in the future.

解决方案

Besides the obvious case: Threads, there is one more:

Are you using your application in debug mode?

The JVM does not hold references to any classloader besides the system one, but it doesn't concern you. The rest of JNI references are either Threads or just debug held objects (provided you don't use JNI and lock the objects down yourself).

JNI references are just roots, edit your answer and post what exactly objects are held by those references.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值