Caleb Jones Caleb Jones - 1 year ago 627
Android Question

Memory leaks with MapView in a RecyclerView

I've already checked a bunch of other questions but none of the solutions have worked, I'm not using googleMap.setMyLocationEnabled(true) so thats not the problem.

The adapter that I am loading the MapView in is located here.

public void onMapReady(GoogleMap googleMap) {
//TODO: Allow user to update this 1-normal 2-satellite 3-Terrain

gMap = googleMap;


// If we have map data, update the map content.
if (mMapLocation != null) {

The map loads fine and functions, I'm just getting Out of Memory errors after orientation changes.

Heres the output of LeakCanary:

In me.calebjones.spacelaunchnow.debug:1.0.0-DEBUG:28.
* me.calebjones.spacelaunchnow.MainActivity has leaked:
* GC ROOT$a.f
* references
* references maps.dg.p.mParent
* references android.widget.FrameLayout.mParent
* references
* leaks me.calebjones.spacelaunchnow.MainActivity instance

  • Retaining: 2.3 KB.

  • Reference Key: 9007ff6a-0072-49ce-b8cc-afc17cb19a76

  • Device: motorola google Nexus 6 shamu

  • Android Version: 6.0.1 API: 23 LeakCanary: 1.4-beta1 02804f3

  • Durations: watch=5791ms, gc=156ms, heap dump=11974ms, analysis=85902ms

Answer Source

Did you try adding this to your manifest, in the activity tag?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download