# 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)
#
出現(xiàn)上面問題主要是因爲(wèi)內(nèi)存不足鹏氧,要啓用swap分區(qū):
通常,Linux系統(tǒng)中swap分區(qū)可以通過兩種方式指定佩谣,分別為:一把还、在磁盤分區(qū)的時(shí)候格式化一個(gè)swap分區(qū);二茸俭、在文件系統(tǒng)中創(chuàng)建一個(gè)swap文件作為swap分區(qū)吊履。此文主要介紹第二種方式。步驟如下:
1. 創(chuàng)建文件
sudo fallocate -l 8G /swapfile
說明:8G 表示swap文件大小调鬓,/swapfile為swap文件路徑和名稱艇炎,可以任意指定。
2. 修改文件權(quán)限
sudo chmod600/swapfile
3. 將 swapfile 初始化為交換文件
sudo mkswap /swapfile
4. 啟用交換文件
sudo swapon /swapfile
5. 至此腾窝,linux系統(tǒng)已經(jīng)將swapfile作為交換文件使用缀踪,但是重啟之后是不會(huì)自動(dòng)掛在剛才創(chuàng)建的文件的,因此需要手動(dòng)修改 /etc/fstab 配置文件:
sudo gedit /etc/fstab
6. 在文件中添加如下內(nèi)容:
?/swapfile none swap sw00
7. 完成虹脯,測試下:
sudo swapon -s
提示:
如果需要卸載swap分區(qū)文件辜贵,可以使用命令:swapoff /swapfile