Native memory allocation (mmap) failed to map

后端 未结 3 1056
[愿得一人]
[愿得一人] 2021-02-08 00:00

I have started facing Native memory allocation issue. I guess could be related with the -Xmx and -Xms settings. What is the recommended way to set this values ?

Currentl

相关标签:
3条回答
  • 2021-02-08 00:27

    Possible solutions:

    • Reduce memory load on the system
    • Increase physical memory or swap space
    • Check if swap backing store is full
    • Use 64 bit Java on a 64 bit OS
    • Decrease Java heap size (-Xmx/-Xms)
    • Decrease number of Java threads
    • Decrease Java thread stack sizes (-Xss)
    • Set larger code cache with -XX:ReservedCodeCacheSize=
    0 讨论(0)
  • 2021-02-08 00:32

    You are clearly asking for a lot more than is physically available on your system. You have 16GB total but it's 90% in use, and you don't have any swap space, so there's no way you're getting -Xms6G let alone more (-Xmx13G).

    You need to figure out what other processes are consuming memory using, for instance, top and sort by resident memory (upper-case letter O, then q), and stop enough of them to free up at least 6GB before running your JVM.

    That, or double your physical memory to 32GB, or add 16GB of swap (but that could result in thrashing if the system is heavily loaded).

    0 讨论(0)
  • 2021-02-08 00:37

    Jim Garrison provided a good answer as to why op is getting that issue.

    I would like to address a secondary question of the op:

    I read that is recommended to set same values but without any explanation of why.

    Basically, the JVM will allocate whatever you put in -Xms as soon as the JVM starts, then grow as required to -Xmx, once that is reached, it goes garbage collecting (flushing things no longer used).

    Running GC on lots of objects (here 7Gb worth of objects) is not a good idea because it will take time and a lot of resources. Setting them to the same value is OK, as GC is collected along the way. GC has operations that are "stop-the-world", where nothing else can run while garbage is collected. Now imagine cleaning up 7Gb of garbage, that is going to take a non-negligible amount of time and cause long pauses.

    You really should read https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/introduction.html

    0 讨论(0)
提交回复
热议问题