I am facing OOM issue as the supportMapFragment doesn't get destroyed.
Xml used:
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Code snippet :
mMapFragment = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map));
GoogleMapOptions mapOptions = new GoogleMapOptions();
mapOptions.useViewLifecycleInFragment(true);
mMapFragment.newInstance(mapOptions);
//ondestroy calling
@Override
protected void onDestroy() {
super.onDestroy();
//clear all the data
mMap.clear();
mMapFragment.onDestroyView();
}
Followed the same as mentioned in the docs given: https://developers.google.com/android/reference/com/google/android/gms/maps/SupportMapFragment