程序报错内存不足Cannot allocate memory

执行任何java程序都报错额内存不足,启动不了程序,包括jps都不行。

'hadoop version' returned:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e0000000, 175112192, 0) failed; error='Cannot allocate memory' (errno=12)
# # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 175112192 bytes for committing reserved memory. # An error report file with more information is saved as: # /data/hadoop/soft/hive2.3.4/bin/hs_err_pid12345.log

但是查看io和内存都没问题

程序报错内存不足Cannot allocate memory_第1张图片

 

后来经过排查使用如下方案解决

使用ulimit -a 可以查看当前系统的所有限制值,使用ulimit -n 可以查看当前的最大打开文件数。

新装的linux默认只有1024,当作负载较大的服务器时,很容易遇到error: too many open files。因此,需要将其改大。

使用 ulimit -n 65535 可即时修改,但重启后就无效了。(注ulimit -SHn 65535 等效 ulimit -n 65535,-S指soft,-H指hard)

有如下三种修改方式:

1.在/etc/rc.local 中增加一行 ulimit -SHn 65535
2.在/etc/profile 中增加一行 ulimit -SHn 65535
3.在/etc/security/limits.conf最后增加如下两行记录
* soft nofile 65535
* hard nofile 65535

你可能感兴趣的:(linux)