From this post Strong references never be garbage collected, With this understanding I assume if we create a infinite Strong Reference objects
in memory then it must throw OutOfMemory
error.
However, When I ran below dummy program it never through OutOfMemory
error although I have created infinite objects in while loop.
public class Test2 {
public static void main(String[] args) {
while (true) {
Test2 obj = new Test2();
System.out.println(obj);
}
}
}
Please help me understand if strong referenced objects are never garbage collected then how come there is no OOM
error.