Is there a way to launch an aggressive and complete garbage collection in Java?

Posted by Gnoupi on Stack Overflow See other posts from Stack Overflow or by Gnoupi
Published on 2010-04-06T13:10:30Z Indexed on 2010/04/06 13:13 UTC
Read the original article Hit count: 161

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about garbage-collection