Google Maps - Out of memory exception

2019-06-01 10:52发布

问题:

I am using Google Maps v2 and am getting following error:

E/qdmemalloc(17414): ion: Failed to map memory in the client: Out of memory
E/qdgralloc(17414): Could not mmap handle 0x7e55bf40, fd=143 (Out of memory)
E/qdgralloc(17414): gralloc_register_buffer: gralloc_map failed
E/GraphicBuffer(17414): unflatten: registerBuffer failed: Out of memory (-12)

The app doesn't crash yet, but the map isn't shown anymore. When I load the activity that contains the map again, the app shows a warning and crashes with the following error message:

Warning:

<sharedmem_gpumem_alloc_id:1431>: sharedmem_gpumem_alloc:
   mmap failed errno 12 Out of memory

Error:

<ioctl_kgsl_sharedmem_alloc:1532>:
    ioctl_kgsl_sharedmem_alloc: FATAL ERROR : (null)

I think the problem might be the usage of custom icons:

googleMap.addMarker(new MarkerOptions()
 .position(chargingStationObject.geoData)
 .title(chargingStationObject.name)
 .snippet(chargingStationObject.stationAvailability)
 .data((chargingStationObject.id))
 .icon(iconDescriptor_gray));

Is there a way t prevent that from happening? Using smaller bitmaps for icons, for example?

回答1:

As as workaround I added largeHeap=true to the AndroidManifest.xml. It seems to be working, I'd like a more elegant solution however.