简体   繁体   中英

Android touch event list and garbage collector

My game has been stuttering because of the GC and it ranges from 40ms to 140ms. My game is not creating new objects or anything in the update or render threads so I'm pretty sure my project is clean EXCEPT for one. In the update method I have a List<TouchEvents> touchEvents = getTouchEvents(); I am pretty sure this is what is causing the GC to kick in as it only GC every time I'm moving around as it requires me touching the screen (using the ACTION_MOVE event). How would I optimize or prevent this?

EDIT: Now I'm starting to think it has to do with my FPS limit method. I'm assuming since I am limiting FPS to 30 the GC does not have enough time without interfering with my game. I came up with this theory after I took the limiter off and ran my game at full 60FPS. The game goes PERFECTLY SMOOTH when running at 60FPS but not at 30FPS. Any ideas?

Personally I wouldn't recommend capping the fps. Instead, let it run as fast as it can and refer to elapsed time when doing movement and physics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM