When to use System.runFinalization() and System.gc() ??

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi,

When should I use System.runFinalization() and System.gc() in a Java program ? Thanks in advance !!
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
You shouldn't have to for most applications. The Java VM does a pretty good job cleaning up after itself automatically.
 

kmthien

Senior member
Oct 8, 2002
363
0
0
Then why Java still offering this function ?? Thanks a lot for your valuable comment !!!!
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
No, you should probably leave the Java virtual machine to its own garbage collection devices rather than force a full garbage collection cycle. Unless you are writing something that is allocating extremely large amounts of memory, there is no need to force a garbage collection.