首页 > 其他 > 详细

013 - 关于GC root: Native Stack | MAT分析

时间:2018-05-05 10:39:28      阅读:231      评论:0      收藏:0      [点我收藏+]

 
Question:
 
I have some third library code that I run and after some time I run into OutOfMemoryError. So I fired up the Eclipse MAT and analyzed the memory. Now it seems the memory can‘t be disposed because there is an object that is a shown as GC root: Native Stack
 
 
Answer:
 
Objects being shown as GC root: Native Stack turned out to be a problem of the Eclipse Debugger. When the application was started without the debugger (i.e. with ‘run‘ instead of ‘debug‘) the problem disappeared. This was also the reason that I couldn‘t find the code where the objects where used in JNI inside my project (cause they weren‘t).
The same problem appears when using IntelliJ Debugger
 
 
简单说:
   通过Eclipse或者IntelliJ  采用debug模式启动程序时,发生内存溢出错误后,由于存在 GC root: Native Stack,导致发生错误的方法中创建的对象无法释放 (正常情况下,发生错误后,方法调用结束,对象会被正常释放的)。
解决方法:采用run运行(非debug模式),就不会存在该问题了013 - 关于GC root: Native Stack  |  MAT分析

013 - 关于GC root: Native Stack | MAT分析

原文:https://www.cnblogs.com/756623607-zhang/p/8993885.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!