Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 2
    Though it is also possible to view the contents of a program's memory space during its operation. Deleting of memory just removes the pointer to the memory (much like the deletion of a file removes the file pointer to the file from the filesystem) Overwriting it helps keep it "secure." Commented Dec 4, 2014 at 16:35
  • 9
    Assuming that overwriting it actually overwrites it, and doesn't just move the pointer to some new section of memory with the new values (which means the old data sticks around until the memory is reused, just like with deleting it). Commented Dec 4, 2014 at 16:52
  • 9
    @Desthro: Unless you're working in real mode (i.e. you're writing an OS kernel), pointers are typically only virtual memory address; only the kernel has access to real memory addresses. It is certainly possible for the operating system to move the two memory pages to a different real address when the memory is overwritten, this can be done without changing the virtual address. This happens during swapping for example. Commented Dec 4, 2014 at 17:37
  • 3
    I think you'd definitely want the volatile keyword to make sure that what happens is actually an overwrite Commented Dec 5, 2014 at 1:48
  • 4
    @raptortech97 does volatile actually ensure that though? Suppose a process is suspended and its memory paged out before the sensitive variable can be overwritten, then it's later resumed. There's no guarantee the virtual memory will be paged back into the same section of physical memory, is there? In such a case volatile doesn't guarantee an overwrite. I think. I'm honestly not sure though. (volatile prevents certain compiler optimizations, I get that, but it seemed like you were saying it does more than that) Commented Dec 5, 2014 at 8:57