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: 
Using the [*Java™ Virtual Machine Tool Interface (JVM TI)*](http://docs.oracle.com/javase/7/docs/technotes/guides/jvmti/), the function

```
jvmtiError ForceGarbageCollection(jvmtiEnv* env)

```

will "Force the VM to perform a garbage collection." The JVM TI is part of the [*JavaTM Platform Debugger Architecture (JPDA)*](http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/).
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>