开发者

java.lang.OutOfMemoryError comes after some time of period...?

开发者 https://www.devze.com 2023-03-17 04:11 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消