java程序在运行过程中报内存不足,

问题遇到的现象和发生背景

此程序是按照设定量每次定量统计数据,当执行一定次数后报内存不足

报错内容
#
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00007ff60d6d9000, 262144, 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 262144 bytes for committing reserved memory.

An error report file with more information is saved as:

/u01/app/hs_err_pid121537.log

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00007ff855f03000, 65536, 1) failed; error='Cannot allocate memory' (errno=12)
[thread 140703030978304 also had an error]

我的解答思路和尝试过的方法

通过free -h 查看内存使用率很低
total used free shared buff/cache available
Mem: 31G 4.4G 25G 699M 1.4G 25G
Swap: 5.0G 0B 5.0G

我想要达到的结果

这个问题应该通过什么方法来解决

加个内存条,容量太小,不能优化

内存不够用,加内存。