1

我正在使用 Busybox 测试和嵌入 linux CPE;

BusyBox v1.00 (2012.07.10-03:48+0000) multi-call binary

我想尝试消耗盒子上所有可用的虚拟内存来测试 OOM 杀手的行为。

这里的内存统计:

# free
          total         used         free       shared      buffers
Mem:        27876        21824         6052            0          708
Swap:            0            0            0
Total:        27876        21824         6052
#

问题是 CPE 上的工具非常有限,因此“vi”、“dd”之类的命令不存在。

我在网上找到一篇文章:http: //linuxdevcenter.com/pub/a/linux/2006/11/30/linux-out-of-memory.html

但是由于设备上缺少内置工具,因此在执行脚本时遇到了问题。

有什么想法可以在命令行上消耗所有可用内存吗?

4

1 回答 1

1

I haven't tested it under busybox but i fork bomb may do the trick (I belive :(){ :|: & };:) should work on any ksh). It will spawn processes recursively so it will consume all of resources at some point (unless you run out of, say, pids faster - but I would think that on embedded devices memory is primary concern).

于 2012-12-20T09:29:26.733 回答