You don’t have to worry about forcing the use of GC unless you write, say, a tool like VisualVM yourself.
NetBeans, IntelliJ, VisualVM, and many others can push GC, not hint, but actually force. Using JVMTI, you can force GC.
BUT again you are likely to do NOT to do this.
You press GC (not a hint) using the JVMTI ForceGarbageCollection.
However, you probably really DO NOT want to do this (it really can repeat).
Authoritative information on this subject, if you really want to find out (but probably not) how to force, in essence, GC:
http://java.sun.com/javase/6/docs/platform/jvmti/jvmti.html#ForceGarbageCollection
source share