Ubuntu 18.04 运行程序时,报以下错误:
g++: internal compiler error: Killed (program cc1plus)
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report
搞了老半天,终于解决了,记录一下,免得忘记!!!
出现以上问题原因是内存不足,使用交换分区来解决:
1、查看交换分区大小
aoi@aoi-ThinkPad-P15v-Gen-1:~$ free -h
总计 已用 空闲 共享 缓冲/缓存 可用
内存: 15G 1.1G 12G 327M 1.7G 13G
交换: 2.0G 0B 2.0G
aoi@aoi-ThinkPad-P15v-Gen-1:~$ swapon --show
NAME TYPE SIZE USED PRIO
/swapfile file 2G 0B -2
//由于我之前的错误操作创建了swap,所以这里显示已存在
aoi@aoi-ThinkPad-P15v-Gen-1:~$ mkdir /swap
mkdir: 无法创建目录"/swap": 文件已存在
2、进入到根目录
aoi@aoi-ThinkPad-P15v-Gen-1:~$ cd /
aoi@aoi-ThinkPad-P15v-Gen-1:/$ ls
bin etc lib lost+found proc snap sys vmlinuz
boot home lib32 media root srv tmp
cdrom initrd.img lib64 mnt run swap usr
dev initrd.img.old libx32 opt sbin swapfile var
aoi@aoi-ThinkPad-P15v-Gen-1:/$ cd swap
aoi@aoi-ThinkPad-P15v-Gen-1:/swap$ ls
swapfile //swapfile这个也是我之前错误创建的
aoi@aoi-ThinkPad-P15v-Gen-1:/swap$ ll
总用量 24584
drwxr-xr-x 2 root root 4096 12月 25 11:50 ./
drwxr-xr-x 27 root root 4096 12月 25 11:49 ../
-rw------- 1 root root 25165824 12月 25 11:50 swapfile
aoi@aoi-ThinkPad-P15v-Gen-1:/swap$ ll -h
总用量 25M
drwxr-xr-x 2 root root 4.0K 12月 25 11:50 ./
drwxr-xr-x 27 root root 4.0K 12月 25 11:49 ../
-rw------- 1 root root 24M 12月 25 11:50 swapfile
aoi@aoi-ThinkPad-P15v-Gen-1:/swap$ cd ../
aoi@aoi-ThinkPad-P15v-Gen-1:/$ ls
bin etc lib lost+found proc snap sys vmlinuz
boot home lib32 media root srv tmp
cdrom initrd.img lib64 mnt run swap usr
dev initrd.img.old libx32 opt sbin swapfile var
3、删除swap分区
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo rm -rf swap
[sudo] aoi 的密码:
aoi@aoi-ThinkPad-P15v-Gen-1:/$
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo fallocate -l 24G swapfile2
aoi@aoi-ThinkPad-P15v-Gen-1:/$ ll
总用量 27263136
//忘记命令时,可显示帮助
aoi@aoi-ThinkPad-P15v-Gen-1:/$ chmod --help
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo chmod --reference=swapfile swapfile2
aoi@aoi-ThinkPad-P15v-Gen-1:/$ ll
总用量 27263136
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo mkswap swapfile2
正在设置交换空间版本 1,大小 = 24 GiB (25769799680 个字节)
无标签, UUID=c758fa5a-42d9-4894-9626-33d90037db78
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo swapo
swapoff swapon
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo swapo
swapoff swapon
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo swapoff
swapoff: bad usage
Try 'swapoff --help' for more information.
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo swapoff swapfile
aoi@aoi-ThinkPad-P15v-Gen-1:/$
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo mv swapfile swapfile1
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo mv swapfile2 swapfile
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo swapon swapfile
aoi@aoi-ThinkPad-P15v-Gen-1:/$ ll
总用量 27263140
aoi@aoi-ThinkPad-P15v-Gen-1:/$ sudo rm -rf swapfile1
aoi@aoi-ThinkPad-P15v-Gen-1:/$ ls
bin etc lib lost+found proc snap tmp
boot home lib32 media root srv usr
cdrom initrd.img lib64 mnt run swapfile var
dev initrd.img.old libx32 opt sbin sys vmlinuz
aoi@aoi-ThinkPad-P15v-Gen-1:/$
aoi@aoi-ThinkPad-P15v-Gen-1:/$
aoi@aoi-ThinkPad-P15v-Gen-1:/$ free -h
总计 已用 空闲 共享 缓冲/缓存 可用
内存: 15G 2.1G 10G 598M 2.9G 12G
交换: 23G 0B 23G
aoi@aoi-ThinkPad-P15v-Gen-1:/$
aoi@aoi-ThinkPad-P15v-Gen-1:/$
至此,完成 swap 交换分区的扩容。