Profile Image
vishnupriya

What is Java Reduced Use of OS Signals: -Xrs?

What is Java Reduced Use of OS Signals: -Xrs? Have you used this JVM argument before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvm-argument

  • xrs

  • rs

  • Java Reduced Use of OS Signals

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:


• -Xrs


Description:


The -Xrs argument reduces the use of OS signals by the JVM.


In normal mode (i.e. without -Xrs), operating system signals are used by the
JVM for various internal purposes. For example they are used to implement
shutdown hooks that are used to clean up in response to unexpected termination.
Signals may also be used by the JVM to optimize synchronization of all threads
in preparation for a full garbage collector sweep. They may also be used to
optimize branch execution in compiled native code.


However an application that embeds the JVM (e.g. a native application written
in C++) may need to install its own signal handlers. If the JVM also tried to
install these signal handlers then they would interfere with the ones installed by
the embedding application. In this case the -Xrs option should passed to the
embedded JVM.


When -Xrs is used, it can lead to a small decrease in performance because it
reduces the availability of some optimizations. It also means that thread dumps
can no longer be generated, e.g. by sending the SIGQUIT signal on UNIX or
by pressing Ctrl-Break in the console under Windows. Finally, the JVM will
not exit (and shutdown hooks will not execute) in response signals that would
normally cause it to exit.

 

The exact behaviour of -Xrs varies depending on the operating system:


• On UNIX and UNIX-like OSes such as Linux and MacOS, when -Xrs is
used the JVM does not alter the signal masks for SIGINT, SIGTERM,
SIGHUP or SIGQUIT, and signal handlers are not installed for these
signals.
• On Windows when -Xrs is used the JVM does not install a console control handler, therefore it does not process CTRL_C_EVENT,
CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT or CTRL_SHUTDOWN_EVENT.


Most pure Java applications should not use -Xrs. An exception is when the
application runs as a Windows Service, i.e. a continually running background
program that should not exit when the user logs off. By enabling -Xrs in this
scenario, the JVM does not process CTRL_LOGOFF_EVENT and therefore
continues running even when the user logs off.

 

Default Value:


-Xrs is off by default.

Errors:
None


Arguments Related to -Xrs:

TODO: ?


Related Posts:


• IBM documentation regarding -Xrs.


NOTE:


If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your
insights will help the entire 10+ million java developer community to develop
one standard source of documentation for all the JVM arguments.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvm-argument

  • xrs

  • rs

  • Java Reduced Use of OS Signals