`
video.android
  • 浏览: 20111 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Writing Real-Time Games for Android

阅读更多

分享到:
评论
2 楼 video.android 2009-06-26  
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.
1 楼 video.android 2009-06-26  
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.

相关推荐

Global site tag (gtag.js) - Google Analytics