Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

research task: shallow or deep? #13

Open
eostermueller opened this issue Jan 1, 2017 · 2 comments
Open

research task: shallow or deep? #13

eostermueller opened this issue Jan 1, 2017 · 2 comments

Comments

@eostermueller
Copy link
Owner

Need to discover whether the jmap -histo data byte counts are shallow, deep, or somewhere between.

Need to use data from examples in issue #4.

@eostermueller
Copy link
Owner Author

This stackoverflow question suggests a number of things remain unanswered.

@evernat
Copy link

evernat commented Oct 31, 2019

bytes in jmap -histo are shallow, not deep.
For example, this stackoverflow question prints:

 num     #instances         #bytes  class name
----------------------------------------------
   1:       1134597     5834904800  [B
   2:        407694      144032664  [Ljava.lang.Object;
   3:       2018132      111547480  [C
...
   7:        975220       23405280  java.lang.String
...

So the bytes size of String instances are 23405280 / 975220 = 24 bytes exactly per instance (in this JVM).
It is impossible that String instances are only 24 bytes including contents.
So the bytes size in jmap -histo is shallow.

The bytes size depends in fact of the types and numbers of attributes declared in the class and of 32-bits/64-bits/compressed oop. The bytes size can be computed for an object according to the Java Language Specification: see for example, https://stackoverflow.com/questions/52353/in-java-what-is-the-best-way-to-determine-the-size-of-an-object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants