Does garbage collection guarantee that a program will not
run out of memory?



Does garbage collection guarantee that a program will not run out of memory?..

Answer / ranganathkini

Garbage Collection of Java is an automatic mechanism that
safeguards against memory leaks and handles memory
allocation and de-allocation.

The GC makes all possible attempts to free memory and make
it available for fresh allocations. But at certain times it
cannot. At those times, it throws an OutOfMemoryError.

So to conclude, GC handles most of the memory management and
makes all possible attempts to make memory availabe for the
application but it does not gurantee that it will be able to
provide it.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is a vector in java?

0 Answers  


Why for each loop is used?

0 Answers  


Can we have a abstract class withought any method? What is a purspose of this?

3 Answers  


Can I extend singleton class in java?

0 Answers  


Is java se free?

0 Answers  






Can an unreachable object become reachable again?

3 Answers  


why ,we are using jsp and html.which one is better?

2 Answers   Photon,


Can an abstract class be a final class?

0 Answers  


Is a case study a method or methodology?

0 Answers  


How do you identify if jvm is 32-bit or 64-bit from java program?

0 Answers  


How can we handle runtime exceptions? write one sample program? Can we write runtime exceptions beside the throws key word? if yes write sample program?

1 Answers   Huawei,


Given: 1. package test; 2. 3. class Target { 4. public String name = “hello”; 5. } What can directly access and change the value of the variable name? 1 any class 2 only the Target class 3 any class in the test package 4 any class that extends Target

7 Answers   Infosys, WW,


Categories