开发者

Can we increase the priority of the Garbage collection thread in java

As we know in java we have a priority levels for threads, and Garbage collector is a thread with lowest priority. So i w开发者_运维问答anted to know whether for a particular java application can we have its Garbage collector to be more prioritized so that it may increase the memory management for that application.


There are a lot of command line switches which determine garbage collection behaviour in Sun's JVM.

It gets a little complicated, but they're documented here: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html


Basically you want the garbage collector to consume as few system resources as possible, and unless you have very good reason to do otherwise you should leave the system default settings as your adjustments may very well be invalidated by a JVM change or upgrade.

Hence I advise that you do not tinkle with the garbage collection settings. If you have very good reason to do so, please edit your question accordingly.


Do not rely on priority of a daemon thread to get a job done. Say java has 10 level of thread priority but when it maps to native OS thread (say Solaris which has 170 levels of priority) the priority is remapped. Moreover Windows NT has this peculiar habit of increasing thread priority indeterministically by each CPU cycle. Trying to control the flow of app using thread priority can lead to portability issues.

For further details refer this SO question

Depending upon the implementation of JVM higher priority threads may still preempt lower priority threads in time slicing scheme. The addition of time slicing mixes up the processing among threads of the same priority; on a multiprocessor machine, threads may even be run simultaneously. Unfortunately, this feature can lead to differences in your application's behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜