7

I am using -Xmx512m, after out of memory error, I got a heap dump. On loading this heap dump to JAVA VisualVM heap size shown is more than 1 GB.

Not able to understand how heap size has grown to 1 GB when my -Xmx value is 512 MB.

VisualVM Screen shot

EDIT

I looked at the other question for which this question is marked as duplicate , I got one part of answer that JVM has Non Heap memory and other memory parts also ( given in below image )

JVM Memory Parts

But still one question is left. Is there any way I can identify size of only heap memory from a heap dump?

Community
  • 1
  • 1
Vipin
  • 4,851
  • 3
  • 35
  • 65
  • Are you looking just at the file size ? – nos Apr 24 '14 at 12:01
  • @nos No I am looking at Total Bytes. – Vipin Apr 24 '14 at 12:05
  • @nos I want to find out only heap size – Vipin Apr 24 '14 at 12:07
  • 1
    We have edited this question , this is no more a duplicate question. – Vipin Apr 25 '14 at 05:11
  • Can I get your heap dump to investigate what is going on? – Tomas Hurka May 19 '14 at 08:39
  • @TomasHurka I can not provide dump , but you can take any dump for example. – Vipin May 19 '14 at 12:11
  • No, it works fine in other cases. – Tomas Hurka May 19 '14 at 12:46
  • To answer better late than never, no, you can’t calculate the actual heap size from a heap dump, because certain relevant information is missing, e.g. the actual pointer size for references or whether boolean arrays are stored using a byte or single bit per element. Further, the heap dump contains pure object data, whereas the occupation in a runtime heap is subject to address alignment and padding. So an analyzing tool has to do some guesswork about the relevant JVM properties and settings, to estimate the heap size. Speaking of JVisualVM and 2014, it likely didn’t know about CompressedOOPs… – Holger Oct 02 '18 at 09:58
  • @Holger after 4 year now I use XX:NativeMemoryTracking which gives memory information to certain extent(hotspot related memory usages). In JDK 8 it still does not track third party native code memory allocations, dont remember seeing any related update in latest JDK versions as well. – Vipin Oct 02 '18 at 10:41
  • Well, but that native memory is outside the `-Xmx512m` anyway and also not included in the heap dump. So my previous comment only addressed the mismatch between VisualVM’s heap size calculations based on a heap dump and the JVM’s actual heap size, whereas native memory (or and kind of non-heap memory), is another issue. – Holger Oct 02 '18 at 10:55
  • @Holger you are right, I should have read my own question clearly. Recently I was trying to find out resident memory breakup (heap + non heap etc), for that I was using XX:NativeMemoryTracking and my previous comment was related to that. – Vipin Oct 02 '18 at 12:59

2 Answers2

0

Java heap will not be extended than the specified -Xmx. Heap allocation done at the JVM initialization so Heap extension is not possible during the runtime. For more confirmation please add -verbose:gc jvm argument to collect GC occupancy check the last cycle of the logs in order to verify the free space and allocated space of the application.

Mohan Raj
  • 1,104
  • 9
  • 17
  • Please check my updated question at end of edit section. – Vipin Apr 20 '15 at 11:00
  • http://www-01.ibm.com/support/knowledgecenter/SS3KLZ/com.ibm.java.diagnostics.healthcenter.doc/topics/installingagent.html This tool help in monitoring java process on run time . Hope this helps your requirement. – Mohan Raj Apr 20 '15 at 11:10
-3

I think this may help you

https://www.eclipse.org/mat/

I am not sure it can open just the heap memory from a heap dump but it is worth to try

EDIT

You may use JConsole enter image description here

It shows what you are looking for

QGA
  • 3,114
  • 7
  • 39
  • 62
  • 1
    Using Jconsole i can identify heap usages of running java process , but i want to identify heap usages from a heap dump. – Vipin Apr 25 '14 at 18:15