How do you Force Garbage Collection from the Shell? December 16, 2022 by Tarik Since JDK 7 you can use the JDK command tool ‘jcmd’ such as: jcmd <pid> GC.run