Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.4k points)
Is it possible to force garbage collection in Java, even if it is tricky to do? I know about System.gc(); and Runtime.gc(); but they only suggest to do GC. How can I force GC?

1 Answer

0 votes
by (46k points)

Your most suitable option is to call System.gc() which is a reference to the garbage collector that you want it to do a combination. There is no way to force and direct collection though as the trash collector is non-deterministic.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 13, 2019 in Java by Nigam (4k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...