Duplicate: What REALLY happens when you don’t free after malloc?
Let's say, for example:
int main()
{
char* test = new char[50000];
return 0;
}
What happens to the allocated memory after the program had finished? Does it get freed for other applications immediately? Or perhaps after some time? Or maybe it's lost to the system forever? Or does it get swapped to the disk never to return to RAM? Or maybe something completely different?
I would like to know what happens on the major 3 OS's: Windows (XP and up, if there are any differences), Linux, Mac OS X.