Paging is excellent. I am not talking about one of the memory- management schemes by which a computer can store and retrieve data from secondary storage for use in main memory, as defined in Wikipedia. I am not interested in using that feature at the moment. What I am talking about are virtual memory tricks. The fact that we can have a huge continuous virtual memory area, without consuming physical memory excessively, is something really powerful and elegant. The key concepts: a page fault handler, read-only pages, and a physical page full of zeros. These things are very widely known but I keep wondering whether the power of them is harnessed well enough. With 32-bit addressing, there are noticeable limits. With 64-bit addressing, the limits are not so severe.
There are numerous uses for this but best things are usually quite simple: arrays.
Code: Select all
uint32_t hugeStorageArray[0x100000000];
uint32_t GetValue(uint32_t key) {
return hugeStorageArray[key]; /* Every key is valid */
}