I was curious to understand how much memory can I allocate on my laptop, therefore I ran the minimalist program:
#include<stdio.h>
#include<stdlib.h>
int main() {
int Gb = 0;
while ( malloc(1<<30) ){
++Gb;
printf("Now allocated %d Gb in total\n", Gb);
}
}
It should allocate 1Gb of memory at every step, until the malloc fails (NULL), ending the loop. On the other hand, the output that I obtain ends with:
Now allocated 131063 Gb in total
and it cannot definitely be true (I have 8Gb of RAM and no swap partition). Can I ask, what am I misunderstanding?
EDIT: I forgot to mention, I am working with Linux.