I've written the following memory hogging program:
int main() {
while(1) {
auto* blah = new char[1024 * 1024 * 1024]{};
}
return 0;
}
Which, as far I can tell, reserves a whole GB of memory on every iteration on the loop. I was expecting this to crash almost immediately. But it somehow runs until I stop it. Inspecting my system I discovered that my little program is taking up more memory than available on my machine, how is this possible? what's going on here?