Ask Question
30 December, 19:39

I am making a java application, and I need to forcethe garbage collection, how can I

achieve that, if not why?

+5
Answers (1)
  1. 30 December, 22:36
    0
    Hi!

    Runtime objectRuntime = Runtime. getRuntime (); objectRuntime. gc ();

    Explanation:

    First, you have to create an instance of a Java Runtime object. (see the first step of the answer).

    Then, after creating the instance of Runtime object you have to invoke gc () method of the Runtime class. (see the second step of the answer).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “I am making a java application, and I need to forcethe garbage collection, how can I achieve that, if not why? ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers