aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes plz System.gc() example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "plz System.gc() example" Watch "plz System.gc() example" New topic
Author

plz System.gc() example

kanaz tarazen
Greenhorn

Joined: May 26, 2005
Posts: 1
hai guys,

can anybody give me a small example on how garbage collection takes place by using System.gc() ?

thanx

kanaz
Vipin Das
Ranch Hand

Joined: Jul 05, 2004
Posts: 47
Using System.gc() you can just request to run the garbage collector. It may or may not run.
public static void main(String args[[]){
new xyz();
System.gc();
//if gc runs it will garbage collect the above object


}
class xyz{
String p[];
xyz(){
p = new String[200];
}
}

[ May 26, 2005: Message edited by: Vipin Das ]
[ May 26, 2005: Message edited by: Vipin Das ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: plz System.gc() example