I developed a small application for a memory leak stress:
#include
#include
int main(int argc, char **argv)
{
int period =
Why would you expect it to "crash"? If it fails to allocate, malloc() just returns NULL.
Also, note that many modern operating systems (like Linux) typically overcommit the memory, and since your code never actually uses the allocated memory, it can probably do so by a great deal before running out of virtual space and forcing malloc() to fail. This is likely why you see your program using more RAM than is available.
Of course, you failed to say how much swap you have, which will also affect what happens since even if you particular OS doesn't overcommit, it very likely uses swap.