The elimination of objects, that is, garbage collection.
There are two methods related to purging objects:Finalize () and GC ().
(1), this finalize () method is a method of the object class, and any class inherits this method from object.
Note the Finalize () method is called before the object is disposed of as garbage from memory, rather than before the object becomes garbage. But this garbage collector's enablement is not controlled by the programmer, and will not be aroused when the garbage is generated, even if the program terminates, it does not start the opportunity.
As a result, Java provides a System.GC () method to force the garbage collector to recycle, that is, make a call to finalize () to clean up the garbage.
Here's an example:
Tcabinetcard Cabinetcard=t.gettcabinetcardservice (). Get (Strs[1].tostring ()); if (Null==cabinetcard) {Session.write ("Card Error");} else if (Cabinetcard.getcardtype (). Equals ("0")) {Session.write (jsonmapper.tojsonstring (Cabinetcard));} else if (Cabinetcard.getcardtype (). Equals ("2")) {//tcabinetcard cabinetcard = new Cabinetcard; System.GC (); Cabinetcard.setcardtype ("2");//re-assign list List=t.gettcabinetcardservice (). Findlist (Cabinetcard); Session.write (jsonmapper.tojsonstring (list));} else if (Cabinetcard.getcardtype () Equals ("1")) {session.write ("Super User");}
Do not use the new object
The third judgment is judged by the type in the object, which takes the property of the entire object, and reclaims the current object for assignment.
Details to start 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0058.gif "alt=" J_0058.gif "/>650" this.width=650; " Src= "Http://img.baidu.com/hi/jx2/j_0058.gif" style= "White-space:normal; alt=" J_0058.gif "/>650) this.width=650 , "src=" Http://img.baidu.com/hi/jx2/j_0058.gif "style=" White-space:normal; alt= "J_0058.gif"/>
JAVA: Purging and recycling of objects