Can we call garbage collector forcefully in Java?
StackChief LLC
Last updated on
Your thoughts?
Share your thoughts
yes
System.gc()
That is all...
System.gc();
Runtime.getRuntime.gc();
YES
yes
System.gc()
That is all...
System.gc();
Runtime.getRuntime.gc();
YES
© 2022 StackChief LLC. All rights reserved.
StackChiefOG |
Yes but this is NOT recommended...
Garbage collection in Java is non-deterministic. This means you never really know when GC is going to run in Java.
Remember that GC is an automatic process. It kind of does it's own thing and runs on it's own threads. Java is designed for you not to be manually managing memory...