Java Memory Management

Java Memory Mgmt.

Memory management is an important aspect of every application.


Languages like C, C++ does not provide the facility of automatic memory management. So in these programing language, programmer needs to code the logic for managing the memory. In case there is a loophole in the logic then some portion of memory may be improperly reclaimed or lost as well.


These memory loses are referred to as memory leaks.

These small leaks may grow with every iteration and may become so big that would lead to application crashing at some point of time.

Thus we see that managing memory manually is a complex and tough task and it increases the development effort as well.

For this reason, java creators thought of providing the language that would collect memory automatically without requiring any programmer’s intervention at all.


Java provided automatic memory management.

Where does most of the garbage collection occurs?

Heap is the place where objects created in java resides thus is the place where most of the garbage collection occurs.

This is the reason that heaps needs to be free and have enough space to accommodate the new objects. So important task of the garbage collector is to delete any object that is lying idle without any purpose and is out of reach.


We will read more about the garbage collector and its process in next chapter. 

But before we proceed further, lets know few more things.


What is the need of memory management?


  • To remove unreferenced object and create space for something valuable.
  • To free programmers from the worry of writing memory management code themselve.
  • Effective memory utilization so that application doesn't run out of memory during execution.


Please Share this page
Views : 298
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!