3 ms·
Malloc allocates virtual memory. The original article had to issue a correction at the end: "I was wrong about why malloc finally failed! @GodmarBack observes,
by em3rgent0rdr 7y ago
Malloc allocates virtual memory. The original article had to issue a correction at the end: "I was wrong about why malloc finally failed! @GodmarBack observes, in the comments, that x64 systems only have an address space of 48 bits, which comes out to about 131000 GB. So, on my machine at least, the malloc finally failed because of address space exhaustion."
- metrxqin 7y agoThat's incorrect, 2^48 bits = 262144GB actually.
- lifthrasiir 7y agoBut x86-64 divides the 48-bit address space into two halves, only one of which is available in the user mode.
- monocasa 7y agoTo be fair, there's nothing that says the higher half _has_ to be entirely kernel mode. Only that bits 63 through 48 have to be the same value. And Intel has a spec out for a PML5 page table, giving you 57 total virtual address bits.
- unilynx 7y agoThey forgot to mention the kernel gets the top half of the address space, leaving 2^47 for the process. And then it mostly adds up.