Ask Question

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

achieve that, if not why?

+1
Answers (1)
  1. 5 September, 23:13
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers