Ask Question
6 August, 07:07

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

achieve that, if not why?

+3
Answers (1)
  1. 6 August, 10:06
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers