Where objects, methods and variables are stored in memory in Java?


There are five main memory areas which are used to various Java elements. Following is the list of the same.

  • Class Area - This area contains the static members of the class.

  • Method Area - This area contains the method definition and executable code.

  • Heap Area - This area contains the objects which are dynamically allocated/deallocated. if an object is no more referenced by any live reference it is deallocated.

  • Stack Area - This area contains the local variables.

  • Pool Area - Contains immutable objects like string.

Updated on: 30-Jul-2019

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements