Android DDMS 中的对象创建跟踪、VM 内存不足
嘿,我是 Android 新手,如果我错了,请纠正我: 我试图通过 DDMS 监视创建的对象数量和使用的堆(这显然取决于对象的数量)。 在此期间,如果我启动一个应用程序,我就没有。创建的对象。按后退按钮不一定会调用 onDestroy(),因此对象的数量仍然会等于“n”。现在,当我再次启动应用程序时,将再次调用 onCreate() 并再次创建那些“n”个对象(现在对象总数将超过“n”)。 那么,重复这个过程(重新启动应用程序)会导致对象数量不断增加吗? (这显然不应该发生)
Hey, I'm new to Android and kindly correct me if I'm wrong :
I'm trying to monitor the number of objects created and heap used (which obviously depends on the number of objects) through DDMS.
During this, if I start an application, I have 'n' no. of object created. Pressing back button will not necessarily call onDestroy() and hence the number of objects will still be somewhat equal to 'n'. Now, when I again launch the application, again onCreate() will be called and again those 'n' objects will be created (now total no. of objects will be more than 'n').
So, will repeating this process (relaunching the app) will cause a continuous increase in the number of objects ? (which obviously should not happen)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对象的数量会随着创建而增加,然后随着垃圾收集器的运行而减少。
如果即使进行垃圾回收,对象数量仍继续增加,则可能存在内存泄漏。 “hprof”堆转储(可以通过单击 DDMS 中的按钮触发)可以帮助识别原因。
The number of objects will increase as they are created, then decrease as the garbage collector runs.
If the number of objects continues to increase even with garbage collection, then you probably have a memory leak. The "hprof" heap dump (when can be triggered by clicking a button in DDMS) can help identify the cause.