1

私はMapViewを使用しています。 10.0.1。私はメモリリークを取得していますMapViewはアクティビティコンテキストを保持しています。
LeakCanaryトレース:MapViewのコンテキスト保持メモリリークの原因

com.demo.app.ui.main.MainActivity has leaked: 
GC ROOT wl.a 
references oo.a 
references maps.ad.L.g 
references maps.ad.V.c 
references maps.D.i.a 
references maps.D.p.mParent 
references android.widget.FrameLayout.mParent 
references com.google.android.gms.maps.MapView.mContext 
leaks com.demo.app.ui.main.MainActivity instance 

答えて

2

漏れが最も可能性が高い(あなたはそれが設定されている場合)あなたの現在の位置を追跡し続けてGoogleマップから来ています。だからあなたのonDestroy()に以下を追加してください。

@Override 
public void onDestroy() { 

    if (mMapView != null) { 
     mMapView.onDestroy(); 
    } 

    //Clean up resources from google map to prevent memory leaks. 
    //Stop tracking current location 
    if(mGoogleMap != null) { 
     mGoogleMap.setMyLocationEnabled(false); 
    } 
    super.onDestroy(); 
} 
関連する問題