Change Parallel GC to G1GC

Avatar

Avatar

gunpreets102403

Avatar

gunpreets102403

gunpreets102403

27-05-2019

While running my application's performance test, the servers's memory is fully utilized. After the test is completed, memory is not automatically get free.

One of the case i think is i need to change the garbage collector form parallel to G1.

Can anyone guide me how to change the garbage collector in aem and also if you have any other solution of this problem, kindly write it down.

View Entire Topic

Avatar

Avatar

jimt82977416

Avatar

jimt82977416

jimt82977416

17-07-2019

JVM has provided helpful arguments to deal with OutOfMemoryError.  Those JVM arguments are:

  1. -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath
  2. -XX:OnOutOfMemoryError
  3. -XX:+ExitOnOutOfMemoryError
  4. -XX:+CrashOnOutOfMemoryError

In order to diagnose OutOfMemoryError or any memory related problem, one would have to capture heap dump right at the moment or few moments before the application starts to experience OutOfMemoryError. It’s hard to do capture heap dump at the right moment manually because we will not know when OutOfMemoryError is going to be thrown. However, capturing heap dumps can be automated by passing following JVM arguments when you launch the application in the command line:

 -XX:+HeapDumpOnOutOfMemoryError and -XX:HeapDumpPath={HEAP-DUMP-FILE-PATH}

Example:                             

 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/crashes/my-heap-dump.hprof

In ‘-XX:HeapDumpPath’ you need to specify the filepath where heap dump should be stored.

When you pass these two JVM arguments, heap dumps will be automatically captured and written to a specified file path, when OutOfMemoryError is thrown.

Once heap dumps are captured, you can use tools like HeapHero, Eclipse MAT to analyze heap dumps.