暴力测试:
#include <iostream>
using namespace std;
void fun()
{
int *p = new int(10);
}
int main()
{
while(1)
{
fun();
}
}


系统日志查看:
grep "Out of memory" /var/log/messages

待研究:
上面的程序的退出码是多少?
本文探讨了一个线上程序由于Slab内存占用过大触发Linux系统的OOM-Killer导致进程被杀死的问题。通过示例代码展示了一个无限循环中不断分配内存的场景,该场景可能引发系统内存耗尽。日志中通过`grep Out of memory /var/log/messages`可以找到相关错误信息。文章最后提出疑问,关注程序在这种情况下可能的退出码。
暴力测试:
#include <iostream>
using namespace std;
void fun()
{
int *p = new int(10);
}
int main()
{
while(1)
{
fun();
}
}


系统日志查看:
grep "Out of memory" /var/log/messages

待研究:
上面的程序的退出码是多少?

被折叠的 条评论
为什么被折叠?