内存泄漏Android版谷歌地图API第2版 [英] Memory leak for Android Google Maps API v2

查看:98
本文介绍了内存泄漏Android版谷歌地图API第2版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挣扎了内存泄漏问题,在谷歌地图Android的API V2。通过每一个经过我的看法再次变得可见时间约85KB堆的使用量增加:

  • 在手机屏幕关闭(如pressing电源按钮后)。
  • 在用户退出应用程序pressing主页按钮。

该应用程序最终崩溃与内存不足的异常。泄漏不会出现在屏幕上旋转,或通过返回按钮,退出时。任何有关解决办法或后面这个问题的原因的想法?

我的code:

 公共类LeakActivity扩展FragmentActivity {
    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_leak);
    }
}
 

和XML:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:ID =@ + ID / myLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent>

<片段
    机器人:ID =@ + ID / map_1
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    类=com.google.android.gms.maps.SupportMapFragment/>

< / RelativeLayout的>
 

解决方案

这可能是Google地图API中与此相关的悬而未决的问题:

发行4766 - 错误:Android地图API第2泄漏大量内存

使用DDMS转储HPROF工具来转储HPROF文件,用 HPROF-CONV转换和使用的 MAT 检查泄漏。如果它在谷歌地图API,请发布一个APK(或更好的简单测试code)的开放问题,包括HPROF文件。

如果是同样的错误,我遇到了,它可能只发生在Android 2.X,请检查了。

I'm struggling with a memory leak issue at Google Maps Android API v2. The heap usage increases by about 85KB every time my view becomes visible again after:

  • Phone screen turns off (eg after pressing the power button).
  • The user exits the app pressing the Home button.

The app eventually crashes with an OutOfMemory exception. The leak does NOT occur on screen rotate, or when exiting by "back" button. Any ideas about a workaround or the reason behind this problem?

My code:

public class LeakActivity extends FragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_leak);
    }
}

and the XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<fragment
    android:id="@+id/map_1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>

解决方案

This might be related to this open issue in the Maps API:

Issue 4766 - Bug: Android Maps API v2 leaks huge amounts of memory

Use DDMS' "Dump HPROF" tool to dump a hprof file, convert it with hprof-conv and use MAT to examine the leak. If it's in Google Maps API, please post an apk (or better simple test code) to the open issue and include the hprof file.

If it is the same bug I am experiencing, it might only happen on Android 2.x, please check that too.

这篇关于内存泄漏Android版谷歌地图API第2版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆