Garbage Collector in Java

Java is capable of automatically releasing the unreferenced memory. This is achieved when a object is unused. To make a object unused make the reference variable pointing to that object as null pointer. Lets see an Example below, public void TestMethod() { String s = new String(“Welcome to CodeParent”); System.out.println(s); s = null; } Other options in java you can use System.gc() and Runtime.gc() methods, if you call these methods explicitly, the JVM makes efforts towards recycling the unused objects, but there is no guarantee…

Continue reading »