3

我在 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 是否存在我没​​有听说过的已知问题?我可能会问这个用户的任何策略/问题/测试可能有助于确定这里的问题?

4

1 回答 1

1

如果用户有一些经验,也许他可以向您转储内存配置文件,以便您查看分配情况。

有关一些说明,请参阅http://android-developers.blogspot.de/2011/03/memory-analysis-for-android.html

您还可以尝试使用Debug#dumpHprofData()从您的应用程序中转储内存配置文件,并要求用户向您发送该文件。

于 2012-05-04T09:00:14.480 回答