Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Shared Object Memory' vs 'Heap Memory' - Java

What is difference between 'Shared Object Memory' and 'Heap Memory' in Java. Is it like 'Shared Object Memory' is superset of 'Heap Memory'?

The source of this question is documentation of jmap. It provides different options to Print 'Shared Object Memory' and 'Heap Memory'.

like image 660
Sandeep Jindal Avatar asked Jul 28 '11 06:07

Sandeep Jindal


People also ask

Is shared memory in heap?

Heap — This segment contains all memory dynamically allocated by a process. Shared Heap — Contains other types of memory allocation, such as shared memory and mapped memory for a process.

What is the difference between heap memory and stack memory in Java?

Heap memory is used by all the parts of the application whereas stack memory is used only by one thread of execution. Whenever an object is created, it's always stored in the Heap space and stack memory contains the reference to it.

What is the difference between heap and memory?

Overview. Stack memory is the space allocated for a process where all the function calls, primitive data types (int, double, etc.) and local and reference variables of the functions are stored. On the other hand heap memory is used to store the objects that are created during the execution of a Java program.

What is heap memory in Java?

The Java heap is the area of memory used to store objects instantiated by applications running on the JVM. When the JVM is started, heap memory is created and any objects in the heap can be shared between threads as long as the application is running.


1 Answers

Java memory (up to Java 8) consists of 3 parts:

  1. Heap memory.
  2. Non-heap memory (PermGen).
  3. Other memory (JVM own structures).

Memory for all class instances is allocated from the heap. Non-heap memory is primarily used by ClassLoaders to store class-related data.

Some details about shared objects are here: what is shared objects file?.

like image 196
Andrei Petrenko Avatar answered Nov 05 '22 05:11

Andrei Petrenko