【发布时间】:2012-04-23 20:10:14
【问题描述】:
我在 Galaxy Nexus 上使用我的应用程序的用户遇到了问题。这是一款图形密集型游戏,本质上是当他从一个活动切换到另一个活动时,内存逐渐耗尽。
这是一个 Galaxy Nexus,(据我所知)Android 4.0.2。 LogCat 的摘录:
D/.GameViewActivity( 3203): debug. =================================
D/.GameViewActivity( 3203): debug.heap native: allocated 6.01MB of 8.95MB (0.04MB free) in [.GameViewActivity]
D/.GameViewActivity( 3203): debug.memory: allocated: 54.00MB of 64.00MB (14.00MB free)
D/dalvikvm( 3203): GC_EXPLICIT freed 366K, 28% free 40426K/55623K, paused 4ms+4ms
D/dalvikvm( 3203): GC_EXPLICIT freed 1K, 28% free 40425K/55623K, paused 1ms+4ms
不久之后(几分钟),它会如下所示:
D/.MainActivity( 3203): debug. =================================
D/.MainActivity( 3203): debug.heap native: allocated 6.92MB of 11.36MB (0.18MB free) in [.MainActivity]
D/.MainActivity( 3203): debug.memory: allocated: 58.00MB of 64.00MB (1.00MB free)
D/dalvikvm( 3203): GC_EXPLICIT freed 297K, 4% free 58119K/60359K, paused 1ms+5ms
D/dalvikvm( 3203): GC_EXPLICIT freed 3K, 4% free 58116K/60359K, paused 1ms+5ms
I/WindowManager(17943): createSurface Window{41fadf88 .MainActivity paused=false}: DRAW NOW PENDING
D/OpenGLRenderer( 3203): Flushing caches (mode 0)
I/ActivityManager(17943): Displayed .MainActivity: +556ms (total +743ms)
D/dalvikvm(17943): GC_FOR_ALLOC freed 823K, 14% free 24118K/27911K, paused 86ms
D/.GameViewActivity( 3203): debug. =================================
D/.GameViewActivity( 3203): debug.heap native: allocated 6.95MB of 11.36MB (0.15MB free) in [.GameViewActivity]
D/.GameViewActivity( 3203): debug.memory: allocated: 58.00MB of 64.00MB (1.00MB free)
D/dalvikvm( 3203): GC_EXPLICIT freed 11K, 4% free 58488K/60359K, paused 2ms+5ms
D/dalvikvm( 3203): GC_EXPLICIT freed <1K, 4% free 58487K/60359K, paused 2ms+4ms
随后发生崩溃和内存不足。
现在,我已经习惯了 Android 无望的内存管理系统,这导致我的游戏不可避免地崩溃(这是迄今为止 Android 仪表板中报告最多的错误,而且我对内存的删减程度并不重要在应用程序中 - 图形 + Android 内存管理 = 强制关闭)。我只使用 Android 组件 + SurfaceView,尽管使用自定义图形进行了大量皮肤/样式。
然而,引起我注意的是电话。
现在 - 首先 - 它是 Galaxy Nexus,几乎是目前最先进的手机,为其应用程序提供最多的可用内存。很奇怪,这款手机,在所有的手机中,竟然有这种问题。
其次,我有完全相同的手机 - 也运行 4.0.2 - 我将它用作我的主要测试手机。我的用户可以在几分钟内让游戏崩溃;当我玩这个游戏时,它可以运行几个小时,并且始终有 20-25Mb 的可用内存。
第三,这个应用程序每天在数以万计的手机上运行,所以我 100% 确定该应用程序确实没有有任何问题会导致我的用户发生这种灾难性的内存泄漏看到。
简而言之 - 我完全被难住了。
有什么想法吗?这里有人见过这样的东西吗? Galaxy Nexus 是否存在我没有听说过的已知问题?我可能会问这个用户的任何策略/问题/测试可能有助于确定这里的问题?
【问题讨论】:
-
总是有一个设备表现出意外:) 如果用户有一些经验,也许他可以转储你的内存配置文件,这样你就可以查看分配:android-developers.blogspot.de/2011/03/…(或者你做在code)
-
将此作为答案提交,我会接受。向用户发送一个转储 hprof 的测试版本至少可以让我看到他的手机上发生了哪些课程(一堆 Activity 课程),尽管我仍然不明白为什么会在他的手机上发生这种情况,但不是在我的手机上。
-
可能是由不同的设置(如时区、语言或其他系统设置)引起的。设置>开发选项下有一个选项可以更改有关活动管理的某些内容,但我不知道它的作用。
标签: android memory-management memory-leaks galaxy