You're right it's an out-of-memory problem that causes your program to end. But it's not Windows that decides to end it with "Abnormal program termination". It's the C++ runtime ("msvcrt*.dll" on Windows) that raises the std::bad_alloc
exception when new Thing
fails to allocate memory.
You can verify that with a simple change:
#include <exception>
#include <iostream>
class Thing {};
int main()
{
try
{
for (;;) new Thing();
}
catch(std::bad_alloc e)
{
std::cout << "ending with bad_alloc" << std::endl;
}
}
This will end the program normally when the program is out of memory. If you don't catch that exception, the unhandled exception will be handled by the C++ runtime, thus creating that famous "Abnormal program termination" message (or something similar).