I have monitor my java application with profiler to know memory leak. And I got class which taking almost 80% of memory which is
java.lang.ref.Finalizer
Then I google it for above class and found great article
http://www.fasterj.com/articles/finalizer1.shtml
Now can any one suggest me how do I increase FinalizerThread’s priority to collect those object’s in GC.
One more thing I am facing this issue on Linux with kernel version Linux 2.6.9-5.ELsmp (i386) and Linux 2.6.18-194.17.4.el5 (i386) but it’s working fine (without OOM Error) on Linux 2.6.18-128.el5PAE (i386).
Is this issue because of Linux Kernels?
Is there any JVM variable to improve FinalizerThread’s priority?
Thanx in advance.
To answer the question literally you can do this. However as outlined below, it is likely to be pointless, esp as the Thread already has a high priority.
prints
Unless you are using 100% of all your cores, or close to it, the priority doesn’t matter because even the lowest priority will get as much CPU as it want.
Note: On Linux, it will ignore raised priorities unless you are root.
Instead you should reduce the work the finalizer is doing. Ideally it shouldn’t have anything to do. One cause of high load in the finalizer is creating resources which should be closed but are being discarded. (leaving the finalizer to close the resource instead)
In short, you should try and determine what resources are being finalized and make sure they don’t need to do anything when finalize() is called, ideally don’t use this method at all.
It is possible that resources are taking slight longer to close on the older version of the Linux kernel. I would check that the hardware is identical as this could mean it takes longer to clean up resource. (But the real fix is to ensure it doesn’t need to do this)