树莓派编译程序时报错:virtual memory exhausted: Cannot allocate memory
一、原因分析:
树莓派内存太小,编译程序会出现virtual memory exhausted: Cannot allocate memory的问题,可以用swap扩展内存的方法。
二、解决方法:
安装dphys-swapfile软件包,安装后默认设置的swap大小为物理内存的两倍,最大为2G。
Autogenerate and use a swap file
This init.d script exists so one does not need to have a fixed size swap partition. Instead install without swap partition and then run this, with file size (re-)computed automatically to fit the current RAM size.
By default (and hence on installation) it creates swapfile twice as big as the present RAM amount with an upper limit of 2 GB.
参考:https://packages.debian.org/jessie/admin/dphys-swapfile