这里,我使用谷歌地图v2 api在谷歌地图上绘制多条路径(使用折线)。
注意:当点击按钮开始新的谷歌地图活动类并第一次成功绘制路径时,然后单击后退按钮再次启动相同的地图活动类并绘制多条路径。
然后,同样的事情,单击后退按钮并启动相同的地图活动意味着,突然出现内存错误将会到来。错误输出..
04-01 03:12:46.165: E/AndroidRuntime(7803): FATAL EXCEPTION: main
04-01 03:12:46.165: E/AndroidRuntime(7803): java.lang.OutOfMemoryError
04-01 03:12:46.165: E/AndroidRuntime(7803): at java.util.ArrayList.add(ArrayList.java:118)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.google.android.gms.maps.model.PolylineOptions.add(Unknown Source)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.TruckLogics.UserController.UserOrderListMapView.drawdirection(UserOrderListMapView.java:483)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.TruckLogics.UserController.UserOrderListMapView.access$1(UserOrderListMapView.java:453)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.TruckLogics.UserController.UserOrderListMapView$GetRouteTask$1.run(UserOrderListMapView.java:228)
04-01 03:12:46.165: E/AndroidRuntime(7803): at android.app.Activity.runOnUiThread(Activity.java:4673)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.TruckLogics.UserController.UserOrderListMapView$GetRouteTask.onPostExecute(UserOrderListMapView.java:225)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.TruckLogics.UserController.UserOrderListMapView$GetRouteTask.onPostExecute(UserOrderListMapView.java:1)
04-01 03:12:46.165: E/AndroidRuntime(7803): at android.os.AsyncTask.finish(AsyncTask.java:631)
04-01 03:12:46.165: E/AndroidRuntime(7803): at android.os.AsyncTask.access$600(AsyncTask.java:177)
04-01 03:12:46.165: E/AndroidRuntime(7803): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
04-01 03:12:46.165: E/AndroidRuntime(7803): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 03:12:46.165: E/AndroidRuntime(7803): at android.os.Looper.loop(Looper.java:137)
04-01 03:12:46.165: E/AndroidRuntime(7803): at android.app.ActivityThread.main(ActivityThread.java:5103)
04-01 03:12:46.165: E/AndroidRuntime(7803): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 03:12:46.165: E/AndroidRuntime(7803): at java.lang.reflect.Method.invoke(Method.java:525)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
04-01 03:12:46.165: E/AndroidRuntime(7803): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-01 03:12:46.165: E/AndroidRuntime(7803): at dalvik.system.NativeStart.main(Native Method)
预期产出:
启动新活动时,如何清除以前活动使用的内存.. 如何在跳转另一个活动时清除缓存内存..
答案 0 :(得分:0)
在Manifest的应用程序代码中试用android:largeHeap="true"