Skip to content

What does System.gc() and Runtime.gc() methods do?

Posted in Education, and WhoCodeFirst

These methods can be used as a hint to the JVM, in order to start a garbage collection.

However, this it is up to the Java Virtual Machine (JVM) to start the garbage collection immediately or later in time.

Garbage Collection:

The purpose of garbage collection is to identify and discard those objects that are no longer needed by the application, in order for the resources to be reclaimed and reused.

Happy Learning! 😇

If you enjoyed this article, Get email updates (It’s Free)
Translate »