简体   繁体   中英

How to reduce the number of threads used by the jvm

I'm running a single threaded Java app on the following java version:

java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

with the -XX:+UseSerialGC option enabled. Still when I start the application I see multiple threads starting when monitoring the system with htop . I'd like to reduce the number of processes started as much as possible since I have a use case which involves running multiple instances of this application and this will hit the roof of the maximum allowed number of process on the system that I'm running on. Are there any other jvm options other than -XX:+UseSerialGC that I could use to reduce the number of threads starting?

Apart from -XX:+UseSerialGC which disables Parallel or Concurrent GC, there are the following options to reduce the number of JVM threads:

  • -XX:CICompilerCount=1 leaves only one JIT compiler thread.
  • -XX:+ReduceSignalUsage disables Signal Dispatcher thread. Eg JVM will not handle SIGQUIT to dump threads.
  • -XX:+DisableAttachMechanism prevents AttachListener thread from starting.

In theory it is possible to disable even more threads (eg Service Thread and VM Periodic Task Thread) but this would require patching JVM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM