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 Garbage collection Question 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 "Garbage collection Question" Watch "Garbage collection Question" New topic

Garbage collection Question

Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
Need little advise on Garbage collection,

I have heard that whenever the gc process is running, we try to do some other process, it will not execute unless the gc process is complete.

Please let me know if iam correct or wrong.
If wrong, need little details and explaination on the same.

Thanks<br />Dinesh
Marco Ehrentreich
best scout

Joined: Mar 07, 2007
Posts: 1294

Hi Dinesh,

the garbage collector of Java runs as a background daemon in a special thread whenever the JVM is started. Of course it regularly has to do it's job so it obviously consumes resources like CPU power. On a single processor system it's clear that there's no chance for other threads to proceed if the garbage collector thread is active because there's no real multi threading on such system. But unlike earlier version of Java and the JVM the garbage collector is really, really clever and you don't notice it doing its work in normal applications. It would be no problem to provoke lags in your program flow by allocation and deallocation enormous amounts of memory without sense but this would also lead to inefficiencies in programming languages without garbage collector.

I agree. Here's the link:
subject: Garbage collection Question
It's not a secret anymore!