Take the 2-minute tour ×  You can garbage collect in Java simply
by calling System.gc() but sometimes this "stalls" the
application. Is it a bad idea to garbage collect like this and
avoid stalls:  new Thread(new Runnable() {    public void run()
{   Or might this lead to even more problems?  share|improve
this question That will only call System.gc() once ... and don't
you think Java does its garbage collection in another thread
already? –  Marcelo May 31 '11 at 20:56 The question in the
title can be answered with "Yes, the GC is smart. In fact, it's
smarter than you are and it's autonomous." ;) Why do you think
you have to call System.gc() in the first place? And do you
understand what causes these stalls (not all GCs have them, by
the way)? If so, a bit of thinking should answer your question.
If not, you should brush up your understanding of GC in general
and the ones of modern JVMs in particular before you try to
outsmart them. –  delnan May 31 '11 at 20:56 If what you want is
really to tweak the GC to a