A bit tricky here. I ran some tests. A couple of comments:
1- You should always typecast the allocated memory:
char *a = (char*) malloc(1024*1024);
2- If you are allocating 1MB above and I see 1GB in the live bytes, this tells me you are using a for loop (1000 times) like this:
for (int i=0; i<1000; ++i)
{
char* a = malloc(1024*1024);
}
It looks like even though you are allocating 1GB of space and not freeing it; it is showing correctly in instruments - but it is not effectively causing a memory crash because this 1GB space has nothing stored in it. It looks like the compiler might be doing some optimization and ignoring this 1GB and as such there is no memory crash.
3- If you change your code to:
for (int i=0; i<1000; ++i)
{
char* a = (char*) malloc(1024*1024);
memset(a, 'b', 1024*1024);
}
Here you are just allocating the character 'b' to every byte in the 1GB space. This will cause a memory crash. So my conclusion is that the compiler optimizes empty mallocs.
Hope this helps