如何减少jvm使用的线程数 [英] How to reduce the number of threads used by the jvm

查看:557
本文介绍了如何减少jvm使用的线程数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下java版本上运行单线程Java应用程序:

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)

启用 -XX:+ UseSerialGC 选项。仍然当我启动应用程序时,我看到在使用 htop 监视系统时启动了多个线程。我想尽可能减少启动的进程数,因为我有一个用例涉及运行此应用程序的多个实例,这将触及我正在运行的系统上允许的最大进程数量上。除了 -XX:+ UseSerialGC 之外是否还有其他jvm选项可用于减少线程开始的数量?

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?

推荐答案

除了 -XX:+ UseSerialGC 禁用并行或并发GC之外,还有以下选项可以减少数量JVM线程:

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 只留下一个JIT编译器线程。

  • -XX:+ ReduceSignalUsage 禁用Signal Dispatcher线程。例如。 JVM不会处理SIGQUIT转储线程。

  • -XX:+ DisableAttachMechanism 阻止AttachListener线程启动。

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

理论上可以禁用更多线程(例如服务线程和VM周期任务线程),但这需要修补JVM。

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

这篇关于如何减少jvm使用的线程数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆