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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are methods in java?

542


How do you square a number?

585


Which arithmetic operations can result in the throwing of an arithmeticexception?

601


How does linkedhashmap work in java?

521


Can we have return statement in finally clause? What will happen?

520






23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an tag?. code,height & width. 26. What does 'CODEBASE' in an applet tag specify?. Files absolute path.

2063


What is the purpose of a transient variable?

588


What is busy spin, and why should you use it?

590


What is the use of parse function in java?

517


How many threads can java run?

561


How is final different from finally and finalize?

496


I want to re-reach and use an object once it has been garbage collected. How it's possible?

557


Why java is a platform independent? Explain

536


Can you inherit from an abstract class java?

533


What is math in java?

568