File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Regarding Garbage Collection!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding Garbage Collection!!" Watch "Regarding Garbage Collection!!" New topic

Regarding Garbage Collection!!

Ravi Kumar Ravuru
Ranch Hand

Joined: Apr 18, 2002
Posts: 176
Hello Folks,
As everybody know that gc is low priority thread which will be running in JVM in order to track the memory(i mean release the memory for unreferrenced objects).Can we set the priority for gc?I mean highest priority for GC such that it will run for release of memory resources?

Joined: Sep 18, 2003
Posts: 17
i am not sure weather we can set default gc thread´┐Żs priority or not. but u can use System.gc() for garbage collection or can create a thread with System.gc() statement and set priority of that thread.

Wish U Happiness,<br />Sanjeev.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Your basic assumption -- that "GC is a low-priority thread", and that changing the priority would "improve" GC in some way -- is flawed. No such thing is guaranteed or even true in general. The details of how GC works are implementation-specific and vary over time and across vendors.
Now, if you're interested in tuning the GC performance of HotSpot, there is a lot of material available. In particular, see this document. But it's not something you do by trying to fiddle with the priority of "the GC thread."

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Regarding Garbage Collection!!
It's not a secret anymore!