11

I'm tuning the JVM of Java 8 and I'm trying to know what value was defined for the parameter -XX:ParallelGCThreads. The documentation says:

-XX:ParallelGCThreads: Sets the number of threads used during parallel phases of the garbage collectors. The default value varies with the platform on which the JVM is running.

I would like to know what value was defined in my platform and if I need to change that. I don't have in this environment a JDK available, only the JRE.

Dherik
  • 17,757
  • 11
  • 115
  • 164
  • @the8472, thanks for the help! `jinfo` is from JDK I supposed. I have only JRE in the environment. – Dherik Sep 12 '17 at 14:00
  • It appears you have not thoroughly read the linked answer. jinfo is only mentioned as an alternative – the8472 Sep 12 '17 at 14:05
  • @the8472 I see now. But the accepted answer here is more detailed in explaining how to use it. – Dherik Sep 12 '17 at 14:11

2 Answers2

27

Default value :

 java -XX:+PrintFlagsFinal | grep ParallelGCThreads
 uint  ParallelGCThreads                        = 4

If you have a running process jinfo <processId>, if it's not present in the output, it is using the default value (look under VM Flags)

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • 1
    adding the `-version` parameter might be necessary: `java -XX:+PrintFlagsFinal -version | grep ParallelGCThreads` – dube Dec 07 '21 at 15:04
  • 1
    On some JVMs the output is wring to stderr, so redirecting the stderr is required for the grep: java -XX:+PrintFlagsFinal 2>&1 | grep ParallelGCThreads – i000174 Jul 14 '22 at 14:18
5

Consider the default is a fixed number N, as in -XX:ParallelGCThreads=<N>

As per the documentation, that number is based on the amount of HW threads your system has:

On a machine with N hardware threads where N is greater than 8, the parallel collector uses a fixed fraction of N as the number of garbage collector threads. The fraction is approximately 5/8 for large values of N. At values of N below 8, the number used is N.

Luciano van der Veekens
  • 6,307
  • 4
  • 26
  • 30