使用malloc消耗内存使用并在C中休眠

时间:2016-09-25 12:12:44

标签: c memory-management

所以我想用malloc耗尽Windows内存使用量,然后逐步在C中休眠。

我编写了这段代码,但它似乎并没有用尽所有的内存使用量,我不知道还能做些什么。

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char** argv) {
    while (1) {
        malloc(1024 * 1024);
        sleep(1);
    }
    return 0;
}

0 个答案:

没有答案