简体   繁体   English

操作系统何时分配jvm堆

[英]when is the jvm heap allocated by the OS

One of our sap systems(PI ABAP+JAVA stack) was giving performance issue. 我们的一个汁液系统(PI ABAP + JAVA堆栈)出现了性能问题。 The entire 64GB configured for the machine gets hogged up(and the 8 cores as well). 为计算机配置的整个64GB占用了8个内核。 Every one is suspecting the java part,but i think different. 每个人都在怀疑Java的一部分,但我认为有所不同。

The java server nodes where getting restarted with Out Of Memory error. 由于内存不足错误而重新启动的Java服务器节点。 Looking at the hprof files, i found that they where only 1.2G(avg of 3 server nodes) in size , when 3GB(both -Xms and Xmx) of heap is configured for the server nodes. 查看hprof文件,我发现当为服务器节点配置3GB(-Xms和Xmx)堆时,它们的大小只有1.2G(平均3个服务器节点)。 This observation lead to the following doubt. 这种观察导致以下怀疑。

I have read that when Xms and Xmx are set to the same value, the jvm is allocated the entire heap when it starts. 我已经读到,当Xms和Xmx设置为相同的值时,jvm在启动时会分配整个堆。 If its the case the server nodes would have 3GB of heap from the start. 如果是这种情况,则服务器节点从一开始就将具有3GB的堆空间。 If so why does it doesn't reflect in the hprof file or if the hprof contains only the memory allocated to objects during runtime, the the size clearly idicates that the heap memory was free(more than 50%), so how OOM error...!!..?? 如果是这样,为什么它不反映在hprof文件中,或者如果hprof仅包含运行时分配给对象的内存,则大小明显表明堆内存是空闲的(大于50%),因此OOM出错。 .. !! .. ??

I also know that linux does something called as memory over-commit. 我也知道linux做了一些叫做内存过量使用的事情。 ie memory is not actually given when its requested but when its actually used. 也就是说,实际上不是在请求内存时才给出内存,而是在实际使用时才给出。 Is this contributing to the out of memory exception. 这是否导致内存不足异常。 Like when the JVM starts the os says to it that you have been allocated 3GB of memory but actually defers it until its actually required. 就像JVM启动时,操作系统对它说的是,您已经分配了3GB的内存,但实际上将其延迟直到实际需要。 By the time the jvm actually tries to allocate the memory to objects , some other applications might have exhausted the memory. 在jvm实际尝试将内存分配给对象时,其他一些应用程序可能已经耗尽了内存。 Is this possible...?? 这可能吗...??

Even if the java nodes had memory leak issue, wouldn't it be confined to the 3GB of heap. 即使Java节点存在内存泄漏问题,也不会将其限制在3GB的堆中。 How can it hog up the entire 64G of physical memory....??? 如何占用整个64G的物理内存。

One more thing i observed was the swap space was only 50% used. 我观察到的另一件事是交换空间仅使用了50%。

Any light on this...! 任何亮点...!

The hprof doesn't show actual heap size, and its size depends on many things, like enabled/disabled compressed references, field layouting (the object size isn't just sum of sizes of its fields, but also headers and some gaps between fields) and so on. hprof不会显示实际的堆大小,它的大小取决于很多事情,例如启用/禁用的压缩引用,字段布局(对象大小不仅是其字段大小的总和,而且还包括标头和字段之间的一些间隙) 等等。

About memory reserving. 关于内存保留。 The JVM does reserve memory for the heap, but OS doesn't allocate memory until it's needed. JVM确实为堆保留了内存,但是OS直到需要时才分配内存。

I would recommend you to use memory profilers (I highly recommend YourKit profiler) to connect to running virtual machine and then analyze memory usage. 我建议您使用内存事件探查器(强烈建议您使用YourKit事件探查器)连接到正在运行的虚拟机,然后分析内存使用情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM