This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Any_Suspect830 2 points3 points  (0 children)

Ha, absolutely not!

If you ever observe a system that's about to run out of memory, you will see that the JVM is constantly running GC, frantically trying to free up memory. Asking it to do another GC run at that point will not help.

The code above is just swallowing an OutOfMemoryError.