android - Map.setCenter sometimes causes OutOfMemory crashes -
once in while, outofmemoryexception when calling map.setcenter.
stack trace :
java.lang.outofmemoryerror @ java.util.concurrent.copyonwritearraylist.add(copyonwritearraylist.java:267) @ com.nokia.maps.mapimpl.a(mapimpl.java:587) @ com.nokia.maps.mapimpl.a(mapimpl.java:2939) @ com.here.android.mpa.mapping.map.setcenter(map.java:865) @ com.cirrios.smartnavigationlib.ui.mapcontroller$1.run(mapcontroller.java:84) @ android.os.handler.handlecallback(handler.java:733) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5001) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:801) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:617) @ dalvik.system.nativestart.main(native method)
i'm using here premium sdk v3.3.0
any clue on how prevent ?
it's possible happening here periodic task call setcenter()
somehow running @ time when map
not being displayed/drawn.
these setcenter()
events added task queue flushed on every map
draw, if many being added no draw call casue oom issue. sdk clear old events if cancelled new ones prevent this, it's can into.
in meantime, 1 idea prevent if theory correct register onmaprenderlistener
mapfragment
, listen onpostdraw()
callbacks. can use thread safe flag (e.g. atomicboolean
) indicate draw has occurred since last setcenter()
call , call setcenter()
again if true (you flip flag in setcenter
runnable
).
Comments
Post a Comment