You just need a memory leak in some long running process. Here is a minimal example you can try for yourself, if you want to see how OOM looks like:
Code
/*****************************************************************************
* leak.cpp *
* *
* This program creates a nasty memory leak that is likely to crash any Linux*
* computer. Comes with NO WARRANTY. Use at your own risk. *
* *
* To compile, run: *
* g++ leak.cpp -o leak *
*****************************************************************************/
int main() {
while (true) {
long double* p = new long double[1000];
}
}
If you’re going to execute this, it would be a good idea to have the Magic SysRq Key enabled, because you’re going to need to reboot somehow.