title: Can we assume the last 2 bits of a memory address are 00 and reuse those bits? A windows 7 page fault blue screen
body: <p>My friend is programming in c++ on a 64-bit windows 7 PC and he came up with a crazy idea to save a little bit of memory: He observed the last 2 bits of his memory addresses seemed to always be 00, so he figured he could use those bits for other things and then when a memory address is needed, simply use a bit-mask to set the last 2 bits to 0, either when writing or reading memory. The reason why he's only using the last 2 bits is that it needs to work on 32-bit systems too. Anyway, on his Windows 7 64-bit system he got the following blue screen error when running his program: </p>
  
  <p>PAGE_FAULT_IN_NON_PAGED_AREA</p>
  
  <p>Could his crazy memory savings idea be causing this? I.e., can it sometimes happen that the last 2 bits of a memory address are NOT 00, and he's accessing memory that's partly on one of his memory pages, partly off his page? In any event, he needs this to work on ALL popular operating systems. So the question applies to other operating systems as well.</p>
  
  <p>If (in Windows 7 64 bit, at least) his scheme IS guaranteed to work (if coded properly), then what else could be causing the unusual blue screen crash?</p>