Virtual Memory for Linux Processes

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Hello,

If my text is correct, for a running 64-bit Linux process the virtual memory starts at 0x40000000 with nothing lying between 0x00000000 and 0x3fffffff.

This is over 1 billion wasted bytes.

Why?

Thanks.
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Actually, I just realized that the wasted bytes are virtual and would not take up any page frames in physical memory.

But still, why have your process start at some other place other than 0?
 

exdeath

Lifer
Jan 29, 2004
13,679
10
81
Pretty sure its 0x00400000. 32 bit anyway. Not sure about 64.

That's 4 MB from 0.

At the very least 0x00000000-0x00000fff isn't used in order to catch null pointers by convention.

Why 4 MB though? Guessing it has to do with avoiding overlap with any legacy memory space or V86 mode and other issues of backward compatibility and conventions.

And 4 MB = exactly 1 entire page table which is simply one entry in the page table directory.

It's all arbitrary really.

With 64 bit address space it doesn't really matter, we are talking bigger than number of stars in the galaxy (universe?) type numbers.
 
Last edited:

TheRyuu

Diamond Member
Dec 3, 2005
5,479
14
81
If my text is correct, for a running 64-bit Linux process the virtual memory starts at 0x40000000 with nothing lying between 0x00000000 and 0x3fffffff.

It's a 47-bit virtual address space. Also note that if the binary is compiled as a PIE (position independent executable) that address and the address of all libraries (which are PIC) will be randomized.

You can reserve TB's of address space without using any actual RAM if it's not committed. I don't know if you care about Windows but before 8.1 this was not possible because of how it worked and the 44-bit size limit[1]. This limitation was removed in 8.1 (partially because of CFG)[2].

[1] http://www.alex-ionescu.com/?p=50
[2] http://www.alex-ionescu.com/?p=246
 
Last edited: