# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 293601280 bytes for committing reserved memory.
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
# placed in the first 32GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_linux.cpp:2647), pid=10973, tid=11030
#
# JRE version: OpenJDK Runtime Environment (9.0+181) (build 9+181-android4685155)
# Java VM: OpenJDK 64-Bit Server VM (9+181-android4685155, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to /home/dji/project/android_Q/core.10973)
#
出現上面問題主要是因爲內存不足,要啓用swap分區:
通常,Linux系统中swap分区可以通过两种方式指定,分别为:一、在磁盘分区的时候格式化一个swap分区;二、在文件系统中创建一个swap文件作为swap分区。此文主要介绍第二种方式。步骤如下:
1. 创建文件
sudo fallocate -l 8G /swapfile
说明:8G 表示swap文件大小,/swapfile为swap文件路径和名称,可以任意指定。
2. 修改文件权限
sudo chmod600/swapfile
3. 将 swapfile 初始化为交换文件
sudo mkswap /swapfile
4. 启用交换文件
sudo swapon /swapfile
5. 至此,linux系统已经将swapfile作为交换文件使用,但是重启之后是不会自动挂在刚才创建的文件的,因此需要手动修改 /etc/fstab 配置文件:
sudo gedit /etc/fstab
6. 在文件中添加如下内容:
/swapfile none swap sw00
7. 完成,测试下:
sudo swapon -s
提示:
如果需要卸载swap分区文件,可以使用命令:swapoff /swapfile