内核编译出现Memory exhausted解决方案
LD arch/x86/vdso/built-in.o LD arch/x86/built-in.o LD drivers/built-in.o ld: final link failed: Memory exhausted make[1]: *** [drivers/built-in.o] 错误 1 make: *** [drivers] 错误 2
去网上搜了一下,也有人遇到这样的问题,如下:
今天在32bit Ubuntu上面编译Chromium 11 Debug版,报告一个很郁闷的内存用光错误。
- carl@carl-ubuntu-t400:/work/chromium11/src$ make out/Debug/chrome
- ACTION Extracting last change to /work/chromium11/src/out/Debug/obj/gen/build/LASTCHANGE out/Debug/obj/gen/build/LASTCHANGE.always
- LINK(target) out/Debug/chrome
- /usr/bin/ld: final link failed: Memory exhausted
- collect2: ld returned 1 exit status
- make: *** [out/Debug/chrome] 错误 1
仔细检查了link过程中的内存耗用,物理内存基本用光,swap没用到100M就挂了。
后来到网上搜寻了下帮助,据说有可能是ulimit的设置问题,看了下自己的设置:
- carl@carl-ubuntu-t400:/work/chromium11/src$ ulimit -a
- core file size (blocks, -c) 0
- data seg size (kbytes, -d) unlimited
- scheduling priority (-e) 20
- file size (blocks, -f) unlimited
- pending signals (-i) 16382
- max locked memory (kbytes, -l) 64
- max memory size (kbytes, -m) unlimited
- open files (-n) 1024
- pipe size (512 bytes, -p) 8
- POSIX message queues (bytes, -q) 819200
- real-time priority (-r) 0
- stack size (kbytes, -s) 8192
- cpu time (seconds, -t) unlimited
- max user processes (-u) unlimited
- virtual memory (kbytes, -v) unlimited
- file locks (-x) unlimited
将stack size调整了下,重新link,成功!
- carl@carl-ubuntu-t400:/work/chromium11/src$ ulimit -s 16384
由于这种大程序link可能耗光物理内存,所以一定要注意机器散热,内存稍有不稳定,可能连Memory exhausted错误都看不到,而是segment fault。