Friday, May 24, 2013

What happened to java -client?

On our shared server, users are limited to 25 processes. A login script further reduces the soft limit by another 5 processes. This safety margin allows the user to log in an kill something which is using up all their processes. If they want they can raise their soft limit back up to the hard limit.

This works well for most things but java insists on using lots of processes. Confusingly, it prints this message:
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Cannot create GC thread. Out of system resources.
# An error report file with more information is saved as:
# ./hs_err_pid27297.log
The log file is not of much use. It repeats the claim about 'insufficient memory' which is not true and none of the listed solutions will help.

The problem is that the default garbage collector (GC) scales up with the number of CPU cores. Our old server had 8 but the new server has 24. This is easily pushing the users over the 20 thread soft limit.

I don't if the log file lists the number of java threads. If it does I can't work out how to read it. If it could be found it could be compared with the number of available processes:
expr $(ulimit -u) - $(ps x | wc --lines)

In the past I used to solve this problem by adding this to the login script:
alias java="java -client"

but that does not work any more. I don't know when it was removed but it leaves me with the headache of finding a new workaround.

After some research I found this page https://wiki.csiro.au/pages/viewpage.action?pageId=545034311 which suggested using
-XX:ParallelGCThreads=1 -XX:+UseParallelGC
or even just
-XX:+UseSerialGC

This seems to solve the immediate problem but still is not all that useful. To specify the flag to run java you need this syntax:

java -XX:+UseSerialGC

but for javac you have to specify like this:
javac -J-XX:+UseSerialGC


and I don't expect anyone should have to remember that. One simple solution is to alias both those commands but there are many other tools which are part of java which would also need aliases. These other tools may (and do) use their own unique command line parameters which I would rather not have to learn.


Luckily there is also an environment variable you can set like this:
export _JAVA_OPTIONS="-XX:ParallelGCThreads=1 -XX:+UseParallelGC"

however, that makes all the java programs print out this annoying message:
Picked up _JAVA_OPTIONS: -XX:ParallelGCThreads=1 -XX:+UseParallelGC
And the word on the internet is that there is no way to suppress that message.

My solution to use an alias for the most common tools java and javac while keeping the environment variable for all other programs. At first I tried to use this in my alias:
_JAVA_OPTIONS= /usr/bin/java -XX:+UseSerialGC
but an empty variable still shows the message (and best I can tell, bash won't unset a variable like that). I needed to unset it so I had to combine the env command like this:
env -u _JAVA_OPTIONS -XX:+UseSerialGC

My final profile script looks like this:
export _JAVA_OPTIONS="-XX:ParallelGCThreads=1 -XX:+UseParallelGC"
#export _JAVA_OPTIONS="-XX:+UseSerialGC"
alias java="env -u _JAVA_OPTIONS $(which --skip-alias java) $_JAVA_OPTIONS"
alias javac="env -u _JAVA_OPTIONS $(which --skip-alias javac)$(for i in $_JAVA_OPTIONS ; do echo -n " -J$i" ; done)"
You can select which GC you want. I have demonstrated with the more complex example which has two options to be prefixed for javac.

The java users can now happily compile away without java needing the entire machine resources for every invocation.

28 comments:

  1. This news is crucial for all of us. Tawny

    ReplyDelete
    Replies
    1. Nice article. All the sections of your site covered with great functions. I really like the content and discussions on your site. Thanks a lot for allowing me to join. I love to see more about GBWhatsApp. Keep sharing and updating. Also share more posts with us. Thank you.

      Delete
  2. Oracle says that it's discontinuing its Java browser plugin starting with the next big release of the programming language

    showbox apk

    ReplyDelete
  3. Your discussion about the usage limit is enough to say that this is the because in server limit about 25 may be enough other than you can add 5 more users in it.
    Resolved

    ReplyDelete
  4. After everything is polished to a sheen, your find out here project is then uploaded to your customer account. All proofreading and editing services done by this department are not billed.

    ReplyDelete
  5. Mail order brides websites are gaining popularity nowadays, and many men from different continents use them to thai brides find beautiful brides and wives who will become their loyal friend and loving partner for life.

    ReplyDelete
  6. Aw, this was a really nice post. In idea I would like to put in writing like this additionally – taking time and actual effort to make a very good article… but what can I say… I procrastinate alot and by no means seem to get something done.

    Themehunt.com
    Information
    Click Here
    Visit Web

    ReplyDelete
  7. If you want to bring more business and more engaging customers to your brand, it is essential to have website development services. People in US tend to shop online, as social media provides easy and safe access to everybody worldwide. Since the growth of the international market has increased many folds, a website has become a necessity of every business.

    ReplyDelete
  8. Such a beneficial and informational post it is. Moreover, in this era of rapid digitization and modernization in USA, ecommerce website has become a need of every business. If you want to open a door of infinite opportunities from all over the world, then getting yourself an ecommerce website is the best option.

    ReplyDelete
  9. كيفيّة القضاء على السوس استخدام ورق الغار يمكن التخلّص من السوس، خاصةً السوس الموجود في الطحين من خلال استخدام ورق الغار الأخضر، حيث يمكن وضع ورقة واحدة منه في علب الطحين، أو أكياس الطحين المخزّنة، إذ تساعد هذه الأوراق الطبيعيّة على منع دخول السوس، وذلك وفقاً لاعتقادات بعض الناس، ولكن يُراعى استبدال هذه الأوراق كلّ بضعة أشهر، أو عند زوال رائحتها.
    شركة مكافحة حشرات بخميس مشيط
    شركة مكافحة حشرات بتبوك
    شركة مكافحة حشرات بالخبر

    ReplyDelete
  10. We have on board domain experts who are PhD holders from renowned universities across the globe, and we exclusively offer top notch Law Assignment Help Our experts have tremendous experience in furnishing excellent quality Business Law Assignment Help within the shortest of deadlines. Our Tort Law Assignment Help consistently furnish bespoke and non-plagiarized work that fetch excellent grades too. You save a ton of time to prepare well for your term-end exams by seeking the amazingly affordable Commercial Law Assignment Help.

    ReplyDelete
  11. I recommend you to try this ThesisLeader. They provide expert excel help in the USA.

    ReplyDelete
  12. In our company write my essay performers are registered, among which there are those who offer to write any term paper to order. On our website from specialists you can buy inexpensive term paper in any of the disciplines and do not even doubt that you will be satisfied with the result

    ReplyDelete
  13. It's really good to build up information knowledge. My hobby is web surfing. If I have a chance, I will visit you again. The website is really cool. But its necessary to click the link below

    스포츠토토
    파워볼분석
    먹튀검증

    ReplyDelete
  14. I was able to think a lot while looking at this post.
    I will pass this blog to many people. Definitely a good blog is very good. Thank you for sharing.
    토토사이트
    파워볼
    안전놀이터

    ReplyDelete
  15. To get started with norton antivirus, you need to visit Norton.com/setup and enter the norton product key. Norton setup prduct key is a 25 digit activation code.

    ReplyDelete
  16. Download the Canon printer from ij.start.canon and set it up on your device. Canon printers are all in one printer that facilitates print, copy and scan.

    ReplyDelete
  17. To set up your canon printer on any computer, laptop, mobile device, etc., you will need to download the appropriate driver. ij.start.canon So, select the appropriate printer model before downloading the drivers. The foremost thing after that is downloading the printer drivers.

    ReplyDelete
  18. Thanks to Norton's smart internet protection that sets a powerful shield between your system and the internet. Its real-time scanning and firewall ensure that no remote user or random program accesses your computer data without your permission. Visit norton.com/setup to download, install, and activate the Norton security products.

    ReplyDelete
  19. Login to your turbotax.ca/download account. Access your order history and TurboTax desktop software downloads, unlocks, and tax documents.Plug in the machine and power it on. Connect the machine to your computer with the USB cord or pair it via Bluetooth.

    ReplyDelete
  20. Norton setup is a one-stop solution to protect your devices against viruses, spyware, malware, and other threats that lurk around in various forms. Along with protecting you, it also maintains your privacy no matter what device you are using. Having downloaded Norton antivirus via norton.com/setup on your device, you can avoid unsafe websites as well as suspicious downloads, all at once.

    ReplyDelete
  21. Enter Office Product Key to Setup microsoft office 365 or office setup 2019 at office.com/setup. Steps to get office setup product key.

    ReplyDelete
  22. Amazon mytv is a paid online streaming services used at amazon.com/mytv. It gives users access to a wide range of services like fast delivery, watches unlimited videos online, online movies.

    ReplyDelete
  23. Follow these steps to see the current gift card balance via the online Walmart platform: Visit wallmart gift card balance check the platform. Click on the icon showing three lines to expand the sidebar menu and choose Gift

    ReplyDelete
  24. Office setup products helps to enhance your work productivity and help you organize your work sheet more attractively. Download office setup from office.com/setup and enter the office setup product key in order to activate it.

    ReplyDelete
  25. Thank you so much; it was a very wonderful piece of work. A Accounting assignment help or a Paper writer can help you build such technical writing skills. Students, on the other hand, frequently struggle to generate such writing in their coursework and want Coursework Help . I hope that readers and students find this writing instructive and that they take a close look at the writing process in order to improve their skills.

    ReplyDelete