File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

plz System.gc() example

kanaz tarazen

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() ?


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();
//if gc runs it will garbage collect the above object

class xyz{
String p[];
p = new String[200];

[ May 26, 2005: Message edited by: Vipin Das ]
[ May 26, 2005: Message edited by: Vipin Das ]
I agree. Here's the link:
subject: plz System.gc() example
It's not a secret anymore!