Skip to main content

Setting the Process Priority

3 replies [Last post]
Joined: 2003-06-13

Does JDIC allow me to set the process priority for a Java application yet? Frequently I have problems with client side Java apps that'll hit 100% CPU usage far too easily locking out the entire desktop.. avoiding such tight loops isn't easy yield() dosnt help and you're forced to sleep for short periods every 100 iterations to bring the usage down. Plus it isn't always possible because third-party libraries aren't quite as considerate, validating/parsing an XML document via Xerces for example is one sure desktop freeze.

Currently I'm either using the Windows taskmanger to manually change the process priority of javaw processes to below normal, or I've a command line tool that I just need to pass a process name and priority to.. Infact I have a batch file on the desktop to do always do this for IntelliJ IDEA, which makes everything play nice.

I suppose what I really need is to set the priority at launch time. Although I could envision uses via System.exec.

This is important for anybody for anybody running multiple apps at the same time, and doubly so for anybody streaming media, listening to mp3s or recording tv or similar cpu-load/time-sensitive applications at the same time.

A possible Misc addtion?

If the JVM would just stop hoarding memory (in case it needs it again later?) and release some of that heap every now & again.. It'd make the desktop integration much nicer and make for speedier context switches between minimised and on-screen and less paging all-round..?

- Richard

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-08-19

Hi Richard,

I just copied this request as an issue in Issue Track to track it (no additional comment):

Though it can be helpful, I can't see how it can be done as a standalone JDIC API/facility. This is more like an additional option to "java.exe" command.

What's idea ?


Joined: 2003-06-13

Isn't it possible to add an API to allow me to change the priority for the current JVM.. effectively like hardcoding the pid for this command line tool I've been using:
I was expecting it was just a static util JNI MFC type call.

I agree an option on java.exe would be more flexible, allowing a user to express their own priorities.. but how do you go about influencing the JVM teams priorities ;)

- Richard

Joined: 2011-09-09

This thread is ancient, but I found it looking for this very thing. Has anything been done related to this?