How can I disable garbage collection such that it only takes place when I explicitly say so -- i.e., when System.gc() is invoked?

John Mitchell

In general, you can't. That is, the specification of the Java Virtual Machine leaves the implementors of the garbage collection system a lot of freedom.

My big question is why would you ever want to do this? Most of the legitimate reasons that I've heard have to do with getting around various performance issues due to less the awesome collectors in various existing JREs. In those cases, I suggest complaining to the vendor and switching to a JRE with a better collector.

Note that in older versions of the Sun Classic JRE there was a noasyncgc flag that you could specify that would do what you want.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact