System.gc() internally calls Runtime.gc(). It is used to schedule a call to the Grabage Collector. They are to tell the Garbage Collector to run, but the garbage collector will only run when it wants to, needs too. There is no way you can force garbage collector to run. Garbage collector uses an algorithm. The algorithm specifics I don't know, but it definetly has that Garbage Collector will run more often when there is low memory or when impact on the system is minimum if gc is run. There would be other more criteria which I don't know off. Hope this helps. I don't wanna confuse you now.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop