而且我搜索了它的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 © 讓變化成為計劃的一部分