java.lang.OutOfMemoryError comes after some time of period...?
I am working 开发者_如何学Con a app in which I draw 300 lines in Google map.It will work fine some times but some time it will give this error
FATAL EXCEPTION: main
07-01 10:33:38.990: ERROR/AndroidRuntime(10937): java.lang.OutOfMemoryError
07-01 10:33:38.990: ERROR/AndroidRuntime(10937): at java.util.ArrayList.add(ArrayList.java:123)
07-01 10:33:38.990: ERROR/AndroidRuntime(10937): at java.util.Collections$SynchronizedCollection.add(Collections.java:421)
Make sure your ArrayList has a large enough initial size, and that it is not constantly resizing itself as you are adding elements. A resize will cause it to create a copy of itself at a larger capacity everytime its current limit is exceeded. Alternatively, you can use a LinkedList, or even a regular array if the size is to remain fixed.
It looks like your ArrayList has too many elemnts in it. Make sure you really only have 300 lines in your ArrayList. If you do not need points in your ArrayList any more, make sure to either remove them out of the ArrayList, or create a new ArrayList.
精彩评论