So I am looking at a heap with jmap on a remote box and I want to force garbage collection on it. How do you do this without popping into jvisualvm or jconsole and friends?<
Addition to user3198490's answer. Running this command might give you the following error message:
$ jcmd 1805 GC.run
[16:08:01]
1805:
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
...
This can be solved with help of this stackoverflow answer
sudo -u jcmd GC.run
where
is the user that runs the process with PID
. You can get both from top
or htop