需要 Android 堆按摩
我正在尝试在我的应用程序上加载已保存的游戏。问题是,我不断遇到以下问题:
06-01 00:42:36.123: ERROR/dalvikvm-heap(10297): Heap Massage needed (5107596-byte
external allocation too big)
06-01 00:42:36.123: ERROR/dalvikvm-heap(10297): -->Full GC (don't collect
SoftReferences)
06-01 00:42:36.163: ERROR/dalvikvm-heap(10297): -->Heap Massage was successful...
我想我知道为什么。当前的游戏(我想删除并忘记)仍然保留着记忆。我想“解锁”此内存,那么有什么方法可以进行“堆转储”(使用引号是因为我是菜鸟,并且可能使用了错误的技术术语)?
I am trying to load a saved game on my app. Problem is, I keep getting the following problem:
06-01 00:42:36.123: ERROR/dalvikvm-heap(10297): Heap Massage needed (5107596-byte
external allocation too big)
06-01 00:42:36.123: ERROR/dalvikvm-heap(10297): -->Full GC (don't collect
SoftReferences)
06-01 00:42:36.163: ERROR/dalvikvm-heap(10297): -->Heap Massage was successful...
I think I know why. The current game (that I want to be deleted and forgotten) is still retaining memory. I want to "unblock" this memory, so is there any way I can do a "heap dump" (quotes are used as I am a noob and am probably using the wrong technical words)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您消除了对当前游戏数据的所有引用(通过将所有相关变量、哈希条目等设置为
null
),您就可以调用System.gc()
(或 Runtime.getRuntime().gc()) 向 JVM 建议这是进行垃圾收集的好时机。但请注意,您不能以这种方式强制进行垃圾回收。Once you eliminate all references to your current game data (by setting all relevant variables, hash entries, etc., to
null
), you can callSystem.gc()
(orRuntime.getRuntime().gc()
) to suggest to the JVM that this would be a good time for a garbage collection. Note, however, that you cannot force a garbage collection this way.