2017-12-01 11 views
0

私はアプリケーションでMapView + Google Maps APIを使用しています。それは仕事ですが、いつかは記憶に問題があります。私は Android GoogleマップOutOfMemory

のAndroidManifest.xml

largeHeap =を追加しようとしたが、問題は未解決のまま。

トラックログ:私のフラグメントで

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 4194316 byte allocation with 1810320 free bytes and 1767KB until OOM 
     at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java) 
     at android.graphics.Bitmap.nativeCreate(Bitmap.java) 
     at android.graphics.Bitmap.createBitmap(Bitmap.java:977) 
     at android.graphics.Bitmap.createBitmap(Bitmap.java:948) 
     at android.graphics.Bitmap.createBitmap(Bitmap.java:915) 
     at com.google.maps.api.android.lib6.gmm6.vector.gl.k.a(:[email protected]:7) 
     at com.google.maps.api.android.lib6.gmm6.vector.gl.ah.a(:[email protected]:73) 
     at com.google.maps.api.android.lib6.gmm6.vector.gl.ah.a(:[email protected]:46) 
     at com.google.maps.api.android.lib6.gmm6.vector.gl.ah.b(:[email protected]:39) 
     at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.ae.a(:[email protected]:59) 
     at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.am.a(:[email protected]:346) 
     at com.google.maps.api.android.lib6.gmm6.vector.cb.a(:[email protected]:407) 
     at com.google.maps.api.android.lib6.gmm6.vector.bs.a(:[email protected]:664) 
     at com.google.maps.api.android.lib6.gmm6.vector.bs.b(:[email protected]:270) 
     at com.google.maps.api.android.lib6.gmm6.vector.bb.f(:[email protected]:257) 
     at com.google.maps.api.android.lib6.gmm6.vector.bb.run(:[email protected]:11) 

@Override 
public void onResume() { 
    super.onResume(); 
    if (mMapView != null) { 
     mMapView.onResume(); 
     mLocationHelper.checkPlayServices(); 
    } 
} 


@Override 
    public void onPause() { 
     super.onPause(); 
     if (mMapView != null) { 
      mMapView.onPause(); 
     } 
    } 

    @Override 
    public void onStop() { 
     super.onStop(); 
     if (mMapView != null) { 
      mMapView.onStop(); 
     } 
    } 

    @Override 
    public void onLowMemory() { 
     super.onLowMemory(); 
     if (mMapView != null && mGoogleMap != null) { 
      mMapView.onLowMemory(); 
      mGoogleMap.clear(); 
     } 
    } 

    @Override 
    public void onDestroyView() { 
     if (mGoogleMap != null) { 
      mGoogleMap.clear(); 
     } 
     if (mMapView != null) { 
      mMapView.onDestroy(); 
      mMapView = null; 
     } 
     super.onDestroyView(); 
    } 

図書館:

  • プレイサービスマップ:11.4.0
  • プレイサービス-場所: 11.4.0

ありがとうございます!

答えて

0

largeheap=trueは、あなたのアプリに与えられたRAMのサイズを拡張します。たとえば、アンドロイドがアプリごとに1MBのRAMサイズを提供する場合、大きなヒープを有効にすると2MBが割り当てられます。したがって、これは、使用しているメモリが新しい指定された大容量のRAMの下にある場合にのみ、メモリ不足の問題を解決できます。だから、人々はlargeheap=trueがOOMを修正する最善の方法ではないと言うのは、OOMが起きるのを遅らせるだけなので、ほとんどの場合、largeheap=trueせずにOOMを修正することをお勧めします。

使用しているコンテナがわからないのですが、ガベージコレクタでリサイクルできるように余分なメモリを解放するようにコンテナをリフレッシュすることは、OOMを修正する典型的な方法です。まず、手動でコンテナをリフレッシュ(exitと多分入力)して、OOMを解決するかどうかを確認してください。最後に、OOMを防ぐために自動的にリフレッシュするようにコンテナをプログラミングする必要があります。

+0

返信いただきありがとうございます...私はMapViewとGoogle Mapsを破壊した時にはっきりさせました。いくつかの解決策を教えてもらえますか? –

+0

いつOOMを特に体験しますか? –

関連する問題