How to trigger a full gc using JBoss CLI in EAP 6/7

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x

Issue

  • How do I trigger a full gc using JBoss CLI in EAP 6.x/7.x?
  • Is there a command to trigger a full gc using JBoss CLI in EAP 6.x/7.x?

Resolution

Triggering a manual garbage collection is not really a good idea. It should be left to the JVM to decide when and how gc's are done.

You can execute java.lang.management.MemoryMXBean#gc() via the following CLI command.

  • standalone mode
[standalone@localhost:9999 /] /core-service=platform-mbean/type=memory:gc
{"outcome" => "success"}
  • domain mode
[domain@localhost:9999 /] /host=master/server=server-one/core-service=platform-mbean/type=memory:gc
{
    "outcome" => "success",
    "result" => undefined
}

And JMX tools like jvisualvm/jconsole allow you to trigger this, too.

Keep in mind that configurations quite often have the option "-XX:+DisableExplicitGC" which prevents a manual triggering.

Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.