Android谷歌地图控制器内存泄漏
我在使用Android版谷歌地图时,内存严重泄漏。 特别是在使用mapController.animateTo时,我注意到了这一点。参见示例代码:从阿姆斯特丹开始,我通过增加latlng向南驶向意大利,但在3分钟内,堆化超过20Mb,#对象增加到68000或更多,应用程序崩溃。有人知道原因是什么或有解决办法吗Android谷歌地图控制器内存泄漏,android,memory-leaks,map,Android,Memory Leaks,Map,我在使用Android版谷歌地图时,内存严重泄漏。 特别是在使用mapController.animateTo时,我注意到了这一点。参见示例代码:从阿姆斯特丹开始,我通过增加latlng向南驶向意大利,但在3分钟内,堆化超过20Mb,#对象增加到68000或更多,应用程序崩溃。有人知道原因是什么或有解决办法吗 public class MapsLeakActivity extends MapActivity { MapView mapView
public class MapsLeakActivity extends MapActivity
{
MapView mapView = null;
MapController mapController = null;
Location mLoc = new Location("");
GeoPoint mGP = null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mapsleak);
mapView = (MapView) findViewById(R.id.mapviewml);
mapView.setKeepScreenOn(true);
mapView.setSatellite(false);
mapView.setBuiltInZoomControls(false);
mapController = mapView.getController();
mapController.setZoom(17);
// We start in Amsterdam
mLoc.setLatitude(52.29);
mLoc.setLongitude(5.09);
Timer timer = new Timer();
TimerTask moveOn = new TimerTask()
{
@Override
public void run()
{
// Italy here we come ;) (if it wasn't for the memoryleaking)
mLoc.setLatitude(mLoc.getLatitude() - 0.05);
mLoc.setLongitude(mLoc.getLongitude() + 0.05);
mGP = new GeoPoint((int)(mLoc.getLatitude() * 1E6), (int) (mLoc.getLongitude() * 1E6));
mapController.animateTo(mGP);
// System.gc(); Tried this already; does not help!
}
};
timer.schedule(moveOn , 1000, 2000);
}
@Override
protected void onResume()
{
super.onResume();
}
@Override
protected void onPause()
{
super.onPause();
}
@Override
protected void onDestroy()
{
super.onDestroy();
}
@Override
protected boolean isRouteDisplayed()
{
return (true);
}
}