'Shared Object Memory' vs 'Heap Memory' - Java
Asked Answered
L

3

14

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'.

Lhary answered 28/7, 2011 at 6:55 Comment(4)
I suggest you try running it.Mussorgsky
jmap doc says 'When no option is used jmap prints shared object mappings'. Are you able to run jmap without options? For me it just prints Usage instructions (when run 'jmap pid').Hypertonic
If you use JDK6, there is a bug in jmap forums.oracle.com/forums/…. Jmap without options jn JDK6 behaves like jmap -heapRexanna
Adding to Irony, on google 'Shared Object Memory' + Java, almost all the links showed explaining jmap. Sun/Oracle has used this term in 'famous' tool but forget to explain the term.Lhary
L
1

From my analysis so far:

The default option would print all the memory information including:

  • Heap Memory
  • Perm Gen
  • Other Memory (including JNI, Stack space, etc)

This analysis if on the basis of followings:

In JDK docs it is mentioned that the default options (which is 'Shared Object Memory') is similar to pmap command of Solaris. Looking at pmap command, it seems it prints the complete memory information.

Please add comments to validate this understanding.

Lhary answered 28/7, 2011 at 8:47 Comment(0)
R
5

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?.

Rexanna answered 28/7, 2011 at 8:8 Comment(0)
L
1

From my analysis so far:

The default option would print all the memory information including:

  • Heap Memory
  • Perm Gen
  • Other Memory (including JNI, Stack space, etc)

This analysis if on the basis of followings:

In JDK docs it is mentioned that the default options (which is 'Shared Object Memory') is similar to pmap command of Solaris. Looking at pmap command, it seems it prints the complete memory information.

Please add comments to validate this understanding.

Lhary answered 28/7, 2011 at 8:47 Comment(0)
I
0

Shared object memory is where frequently accessed classes of java library are memory mapped so that they can be loaded faster than loading from rt.jar. This includes many commonly used classes like Comparable, String, Object etc. If a requested class file is not available in shared object memory, it is requested from rt.jar. It can be thought of as caching frequently used classes in various java programs.

Infarction answered 27/9, 2011 at 6:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.