我使用谷歌地圖視圖,並使用此代碼添加標記到它:Reycle位圖在Android中
googleMap.addMarker(new MarkerOptions()
.position(chargingStationObject.geoData)
.title(chargingStationObject.name)
.snippet(chargingStationObject.stationAvailability)
.data((chargingStationObject.id))
.icon(iconDescriptor));
iconDescriptor是這樣創建的:
iconDescriptor = BitmapDescriptorFactory.fromResource(getResources()
.getIdentifier("mapicon", "drawable", getActivity().getPackageName()));
當有太多的標記我地圖中,堆被填充到最大值,過了一段時間後,應用程序崩潰,出現內存不足異常。只有在地圖上存在或存在大量標記時纔會發生這種情況。即使在我調用.clear()之後,堆仍然很大。
也許位圖還沒有被正確回收?
有你知道的集羣? –
是循環內的這段代碼嗎? –
@Haresh是的,但我有理由不使用集羣。 – deimos1988