码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-05-05 11:11:59      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:project   nbsp   question   obj   answer   问题   tac   out   mem   

 
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分析

标签:project   nbsp   question   obj   answer   问题   tac   out   mem   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!