Java runtime memory is divided into five different areas, as shown in the following diagram:
Let's look into a brief description of each component:
- Method Area: This contains all the class-level information, such as class name, parent class, methods, instance, and static variables. There is only one method area per JVM, and it is a shared resource.
- Heap Area: This contains the information of all the objects. There is one Heap Area per JVM. It is also a shared resource. As Method Area and Heap Area are shared memory between multiple threads, the data stored is not thread-safe.
- Stack Memory: JVM creates one runtime ...