" Java HotSpot(TM)64位服务器VM警告:无法保留共享内存。 (错误= 12)"

时间:2017-08-30 19:35:43

标签: java tomcat jvm

我使用putty连接VM。我安装了java8和tomcat8。尝试使用tomcat运行应用程序作为远程服务器获取404错误。

所以我重新启动了tomcat。停止服务器时,我收到此错误。任何人都可以知道解决方案吗?

1 个答案:

答案 0 :(得分:4)

当JVM无法从共享内存为Java堆分配大页面时,可能会出现

无法保留共享内存消息。这可能仅在-XX:+UseLargePages开启时发生。

errno = 12 表示“内存不足”。

来自HotSpot sources的解释:

// Possible reasons for shmget failure:
// 1. shmmax is too small for Java heap.
//    > check shmmax value: cat /proc/sys/kernel/shmmax
//    > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax
// 2. not enough large page memory.
//    > check available large pages: cat /proc/meminfo
//    > increase amount of large pages:
//          echo new_value > /proc/sys/vm/nr_hugepages
//      Note 1: different Linux may use different name for this property,
//            e.g. on Redhat AS-3 it is "hugetlb_pool".
//      Note 2: it's possible there's enough physical memory available but
//            they are so fragmented after a long run that they can't
//            coalesce into large pages. Try to reserve large pages when
//            the system is still "fresh".

按照上面的说明操作,或者只删除-XX:+UseLargePages JVM选项。