Octacone wrote:
64 GB = 64 * 1024 MB = 64 * 1024 * 1024 KB = 64 * 1024 * 1024 * 1024 Bytes = 68719476736 Bytes conatined in 64 GB of RAM.
We don't want to store 68719476736 different addresses, we want to store blocks of memory (4 KB chunks).
4 KB = 4096 Bytes --> 68719476736 / 4096 = 16777216 Bytes/Addresses to store.
Now since we are using a bitmap there are 32 bits inside a single uint32_t, so we need to divide 16777216 by 32 = 524288 addresses to store in total.
524288 addresses = 524288 different variables = each one of them being 4 bytes so 524288 * 4 = 2097152 bytes in total to store them = exactly 2 MB.
Wow! I was missing the last line...
Good catch.
Well, I wouldn't say you missed the last line, instead I'd drop the use of uint32_t in the math (though not necessarily in code). You need the 16 mega _bits_, and since each byte is 8 bits that means 16/8 = 2 MiB. By using uint32_t you end up with a number that is 1/4 of what it should be, then you multiply it with 4 to get the correct result, just redundant to essentially divide and multiply by the same number in a sense..
But anyway, as said, my main point was that for a full 64-bit PAS you'd waste a lot of memory, unless you record the base address, so you don't need a full bitmap for the entire 64-bit PAS, given that no hardware even supports the full 64-bit PAS, AFAIK.