最近公司的linux server有个问题
以前装32G的ram工作正常, 内存超过了就用page
最近把ram加到64G, 发生奇怪的问题
内存用量到24G时就会整个系统卡住, 连page也不用了
因此我想写一个程式如下
int main(void){
unsigned long int total = 0;
unsigned long int size = 1000000;
while (size > 0) {
char *p = malloc(sizeof(char) * size);
if (NULL != p) {
total += size;
output(total);
}
else {
size /= 1000;
output(total);
}
} output(total);
return 0;
}
output函数就不附上了, 就是显示用了多少G而已
这城市compiler后, 执行的成果
永远都在4G又275M
但我的系统有64G啊
请问是不是有其他的写法可以让我占用全部的RAM测试一下呢?