You should read this thread I made once: So I use System.gc() manually, is it really that bad ?
The basic things were mentioned:
- dont use it as a general rule
- and its just a suggesting, dont a command per se
also the garbage will be collected automatically and if needed anyway.
That being said, I do use it in out big game. Whenever a new map is loaded, I call System.gc(). Because if you have map change / loading screen, that is really the best time to this, so I say "yeah go ahead and clean out the garbage now, if its convenient" aka System.gc() - because generally I would prefer it to happen during the map change and not during the game which can potentially cause a short lag... which I'm 99% sure wont happen, but you know *shrug*
so thats the only place to use this
if you feel that a certain place would be really nice for a gc() but its not necessary, and this line of code isnt reached too often - go ahead.
Be also aware that the use is "officially" discouraged, meaning "findBugs" and of course freaking "PMD" which are code analysis tools will warn about its usage.
I think findbugs says "should only be used in debug builds"