如果我使用我的机器[Ubuntu 16.04 64位,内核4.4]一段时间,QEMU需要内核caching丢弃,否则,它不会pipe理分配内存。
为什么会发生?
这是一个示例运行:
~$ free -m total used free shared buff/cache available Mem: 15050 5427 3690 56 5931 4803 Swap: 0 0 0 ~$ sudo qemu-system-x86_64 -m 10240 # and other options qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory ~$ echo 3 | sudo tee /proc/sys/vm/drop_caches 3 ~$ free -m total used free shared buff/cache available Mem: 15050 1799 9446 56 3803 9414 Swap: 0 0 0 ~$ sudo qemu-system-x86_64 -m 10240 # and other options qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory ~$ echo 3 | sudo tee /proc/sys/vm/drop_caches 3 ~$ free -m total used free shared buff/cache available Mem: 15050 1502 10819 56 2727 10784 Swap: 0 0 0 ~$ sudo qemu-system-x86_64 -m 10240 # and other options # Now QEMU starts
并非所有caching的数据都可以立即丢弃。 例如,caching的脏页必须先写回到磁盘,才能从RAM中删除。 你没有交换,所以直到这些写入完成,QEMU没有足够的可用空间。
你真的应该添加一个合理的交换量。 你不能指望内存pipe理者一手抓好背后的工作。