When Will system. GC () be called in the game ()? [Javame]

Source: Internet
Author: User
I don't know if you have seen the "decompilation of Siberian attacks" Source code " Code Okay, I don't know how powerful its authority is, but it is still famous to attack the game in Siberia. It may be worth looking.
Its main engine is to declare a static image array: Class Mainengine Extends Fullcanvas
Implements Runnable
{
....
Static Image IMGs [];
Public   Static   Void Initimage () {
If ( ! Isloadimg) {
If (IMGs =   Null )
IMGs =   New Image [gamedata. imgname. Length];
For ( Int I =   0 ; I < Gamedata. imgname. Length -   1 ; I ++ ) {
If (IMGs [I] =   Null ) {
Try   {
IMGs [I]=Image. createimage ("/" +Gamedata. imgname [I]);
}
Catch (Exception ex) {
System. Out. println ("I:"+I );
Ex. printstacktrace ();
}
}
Percent = (I *   100 ) / (Gamedata. imgname. Length -   1 );
SIB. Engine. flushgraphic ();
}
Isloadimg =   True ;
}
}

And I searched its five java files. Under what circumstances does it call system. GC?
The following three situations:
When the user returned to the game (maybe he had answered the call before? Or is the parameter changed ?);
After the user selects an airplane, this may be an option menu. The resources used when selecting an airplane may not be used in the game in the future, so they can recycle it in time;
When the interface is displayed, there is a card at this time, and happy users do not care.

No more.

Nokia documentationKnown issues in the Nokia 6600 MIDP 2.0 implementation v1.7Said:
2.15.1 garbage collecting
Description
Calling 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!
Solution
Do 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

Example
System. GC ();
Thread. Sleep (Delay); delay = 20-50 MS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.