Question: Is it possible to force garbage collection in Java, even if it is tricky to do? I know about `System.gc();` and `Runtime.gc();` but they only suggest to do GC. How can I force GC?

Answer: 
You can trigger a GC from the command line. This is useful for batch/crontab:

```
jdk1.7.0/bin/jcmd <pid> GC.run

```

See :

* <https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html>
I would like to add some thing here. Please not that Java runs on Virtual Machine and not actual Machine. The virtual machine has its own way of communication with the machine. It may varry from system to system. Now When we call the GC we ask the Virtual Machine of Java to call the Garbage Collector. 

Since the Garbage Collector is with Virtual Machine , we can not force it to do a cleanup there and then. Rather that we queue our request with the Garbage Collector. It depends on the Virtual Machine, after particular time (this may change from system to system, generally when the threshold memory allocated to the JVM is full) the actual machine will free up the space. :D