Memory allocation by java

邮差的信 提交于 2019-12-07 14:41:29

问题


Problem : I have setted Xms512m and Xmx1024m for running application which intern use C++ native layer for performing other operation, I am getting OutOfMemory exception when running application. I need to know C++ uses which memory (ie from assigned memory Xms512m and Xmx1024m or it uses other than this setted memory).

How to get heap space and stack space for Java and C++ code while running application separately.


回答1:


The memory allocated by native code is not in the Java Heap. Your OutOfMemory Exception caused by the java application. OOM is a clue to get you a sign that java app may use more than 1024mb memory. You can make it larger or consider the memory leak problem.

There are some links about memory leak detection:

  • Eclipse Memory Analyser (MAT) - Tutorial
  • 10 points about Java Heap Space or Java Heap Memory

You can do it simply:

  • get java app pid by jps
qty:~ qrtt1$ jps
4437 start.jar
10470 Jps
  • get heap dump data by jmap
jmap -dump:format=b,file=my_app_heap_data.hprof 4437
  • use mat to open it, like this:




回答2:


You may use jconsole or VisualVM to see heap usage of the application.




回答3:


You can Use below monitoring applications:
jconsole
javamelody
visualvm




回答4:


The memory allocated to your JVM and the memory used by JNI and native applications are completely different. Tools like VisualVM and Jprofiler can help you determine JVM specific heap usage. If however the memory leak is from JNI or a native application, you should use options like -Xrunjnichk (available on the IBM JDK) to debug JNI calls.



来源:https://stackoverflow.com/questions/9205638/memory-allocation-by-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!