Skip to content Skip to sidebar Skip to footer

Memory Leak For Android Google Maps Api V2

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 of

Solution 1:

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.

Solution 2:

I tried to use System.gc() and map.clear() before the map is initialized.

@OverridepublicvoidonActivityCreated(Bundle savedInstanceState){
    super.onActivityCreated(savedInstanceState);

    if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()) == ConnectionResult.SUCCESS) {
        System.gc();
getMap().clear();
setupmap();


    }
}
 @OverridepublicvoidonLowMemory() {
  super.onLowMemory();
System.gc();
}

Post a Comment for "Memory Leak For Android Google Maps Api V2"