而且我搜索了它的5个java文件,它在什么情况下调用System.gc()呢?下面三种情况:用户返回游戏时(可能之前去接听电话了?或者去设置里改参数了?);用户选完飞机后,这可能是一个选项菜单,选飞机时所用到的资源可能以后在游戏中没必要用,所以及时回收一下;显示过关界面时,这时候有卡的现象,欢喜的用户也不会在意的。
除此之外就没有了。Nokia 的文档Known Issues In The Nokia 6600 MIDP 2.0 Implementation v1.7说:2.15.1 Garbage collectingDescriptionCalling the System.gc() method results in extreme slowness and jamming. In Monty 1.0 VM, garbage collection is different and every time System.gc is called, the entire memory is really cleared. This is an extremely slow process!SolutionDo not call the System.gc method at all, or call the System.gc() garbage collecting method only in non-time-critical situations, such as screen transitions, state transitions, pause states, etc. If the System.gc() method is used, it is recommended to add a short delay (~20-50 ms) after the method call to ensure the sufficient time for the garbage collection, as in the following exampleSystem.gc();Thread.sleep(delay); delay = 20-50 ms
Powered by: BlogJava Copyright © 让变化成为计划的一部分