ITeye博客

Writing Real-Time Games for Android

video.android · 2009-06-23 09:30 · 软件开发 · Markdown

http://player.youku.com/player.php/sid/XOTY0NzAzNjA=/v.swf

评论(2)

  1. #2 楼 · video.android · 2009-06-26 13:41

    Step Two: Don't Call Functions

    OK, that's extreme. But function calls are not cheap and you can't rely on inlining.

    Use static functions whenever possible.

    Don't call functions through an interface. 30% slower than regular virtual functions!

    Accessors and Mutators are my bestest friends in C++,but they have no place in your Java inner loop.

    Be wary of JNI functions. In particular: lots of gl.glXX() functions.

  2. #1 楼 · video.android · 2009-06-26 13:33

    Step One: Memory Management(30:00分钟前后)

    Never allocate memory. Or release it. -Well,never allocate during gameplay. -The GC will stop your game for 100~300ms. That's death for most real-time games.

    Revised:Allocate as much as possible up front,don't release things until you have natural pause time. Invoke the GC manually when you know it to be safe.

    Use DDMS to track allocations. -Hey, Java allocates memory CONSTANTLY. Ugh! -Hidden allocations in things like enum.values(), Class.getClasName(),Iterator,HashMap,Arrays.sort() etc etc etc. Some of these are not really avoidable.

评论功能维护中,当前仅展示历史评论。