Android onTouchEvent()连续触摸导致system_server GC
我有一款需要连续触摸来跟踪用户移动的游戏 并在 SurfaceView 中绘制。我注意到每隔大约 30 秒 system_server 将启动 GC 并导致游戏卡顿。如果 我根本不触摸屏幕system_server不会被GC。我是 想知道其他人以前是否遇到过这个问题。我是 使用 Canvas 一次在屏幕上绘制大约 30 多个对象并运行 非常顺利(56fps),直到 system_server 介入......是这样的 继承SurfaceView的东西?它看起来像 3D 游戏(使用 GLSurfaceView)没有这个问题。
我正在 Samsung Vibrant 上进行开发。
谢谢!
I have a game that requires continuous touch to track user movement
and draws in SurfaceView. I've noticed that at about 30sec intervals
system_server will kick in with a GC and cause the game to stutter. If
I don't touch the screen at all system_server will be not GC. I'm
wondering if anyone else has encountered this problem before. I'm
using Canvas to draw around 30+ objects on screen at once and it runs
pretty smoothly (56fps) until system_server steps in... Is this
something inherit to SurfaceView? It looks like 3D games (using
GLSurfaceView) don't have this problem.
I'm developing on a Samsung Vibrant.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在开始游戏之前分配对象吗?如果您在游戏过程中构造新对象并释放旧对象,GC 不可避免地会启动。
Do you allocate objects before you start the game? If you construct new objects and free old ones during the game, inevitably the GC will kick in.