

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Memory Model
Java memory model is divided between Thread Stacks (One for each thread) and a heap area.
Thread Stack: It is a thread specific memory area and contains local variables, methods call information etc. JVM stacks could be of fixed size or variable size. If computation in a thread exceeds its stack size limit then JVM throws StackOverflowError and exits.
Heap
It contains all the objects created during application lifecycle. The heap is created when the virtual machine starts up. Garbage collector reclaims heap storage for objects and objects are never explicitly deallocated. The JVM is not using any automatic storage management system, and it may vary as per the system requirements. The heap may be of a fixed size or may vary as per requirement. The memory for the heap does not need to be contiguous.
Static variables are stored on heap area and object stored on the heap can be referred by references stored in thread stack.
- Related Questions & Answers
- Java (JVM) memory model
- Shared Memory Model of Process Communication
- What is shared-memory model in computer architecture?
- Differentiate between shared memory and message passing model in OS.
- Memory management in Java
- Java (JVM) Memory Types
- Memory leaks in Java
- Memory Consistency Error in Java
- Out of memory exception in Java:
- How is the java memory pool divided?
- How are Java objects stored in memory?
- How Java objects are stored in memory?
- Difference between Cache Memory and Virtual Memory
- Difference between Virtual memory and Cache memory
- Memory Management