Android onTouchEvent()连续触摸导致system_server GC

发布于 2024-10-09 14:20:44 字数 318 浏览 0 评论 0原文

我有一款需要连续触摸来跟踪用户移动的游戏 并在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荆棘i 2024-10-16 14:20:44

你在开始游戏之前分配对象吗?如果您在游戏过程中构造新对象并释放旧对象,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文