Is there a way to launch an aggressive and complete garbage collection in Java?
- by Gnoupi
For memory optimization reasons, I'm launching myself the garbage collector during profiling, to check if objects are correctly cleaned after disposing of them.
The call to garbage collector is not enough, though, and it seems that there is no guarantee of what it will clean.
Is there a way to call it, to be sure it will recover as much as it can, in profiling conditions (this would have no point in production, of course)? Or is "calling it several times" the only way to be "almost sure"?
Or did I simply misunderstand something about the Garbage Collector?