测量(Android)堆碎片?
我们有一个内存中有大量位图的应用程序。它总是因
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
错误而失败。有可能我们确实使用了太多的内存;我们可能正在泄漏内存;也有可能我们没有做错任何事,而堆碎片才是杀死我们的原因。 (由于 Android 的垃圾收集器不会重新定位活动块,因此我们可能有兆字节空闲,但无法分配 50K。)
有什么方法可以排除碎片吗?我寻找过类似 maxAvail/memAvail 的东西,但没有发现任何合适的东西。
We have an app with lots of bitmaps in memory. It keeps failing with
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
errors. It's possible that we are genuinely using too much memory; it's possible that we are leaking memory; it's also possible that we aren't doing anything wrong, and heap fragmentation is what's killing us. (Since Android's garbage collector doesn't relocate live blocks, we could have megabytes free and be unable to allocate 50K.)
Is there any way to rule out fragmentation? I've looked for something like maxAvail/memAvail, but haven't spotted anything apposite.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会考虑通过 MAT 检查堆。 Eclipse Memory Analyzer 将帮助您确定您实际遇到的问题。
Google I/O 2011 上有一次演讲,涵盖了内存管理和调试主题的一些基础知识。您可以在此处在线观看:http://www.youtube.com/watch? v=_CruQY55HOk&feature=relmfu
I would look into examining the heap via MAT. The Eclipse Memory Analyzer will help you determine which of your proposed issues you actually have.
There was a talk at Google I/O 2011 that covered some basics on the topic of memory management and debugging. You can watch it online here: http://www.youtube.com/watch?v=_CruQY55HOk&feature=relmfu