Hi The above (pathological) test is likely to fail under anything but Linux.
Linux memory allocator does not reserve memory for a process. It makes a promise for memory, but has no intention of fulfilling it. Under memory pressure, it will randomly kill a process to free memory. Ref: Google search for "Linux memory overcommit" This has following implications: 1. malloc/brk calls are fast. System does not do actual reservation. 2. malloc calls never fail. malloc(2G) on a 512MB system will succeed. 3. If process do not actually use what they requested, system can handle more processes than there are resources. 4. When resource crunch happens, someone's gotta get killed. It can well be something important, so system stability is in question. All others (FreeBSD/Solaris/Windows(??)), actually reserve memory for requesting process and malloc returns NULL if it can't allocate memory. Which in short means, that the above test *will* fail for anything but Linux.
