1

We have learned that the information in the hard disk are never erased, only the links to it are erased. Does this apply to RAM as well (as long as the computer is on of course)?

For example, When I declare a variable before I give it a value, the value can be 0 or some other value that was previously in that place.

Can I say that the computer doesn't know how to delete something it just replaces it with another?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Hyorine
  • 9
  • 2
  • 1
    Memory existed before your program runs and will exist after. Unless there is a cleaning procedure, memory remains "as is" and some of its locations will be "replaced" by something else at some time. However for the sake of security/privacy, OSes might clean a memory segment before they allocate it to a process (otherwise you could see what another process stored previously at that location, when it was "owning" the segment). – Déjà vu Feb 12 '22 at 12:50

1 Answers1

0

When a process (program/app) starts, it asks the operating system for some memory. The operating system keeps track of the address/size of the memory each process uses. A process can't access a region of memory it doesn't own (virtual address mapping). When the process ends the operating system may choose to write a value (like 0x00) to all the memory a process had. I believe most existing operating systems don't overwrite memory.

Take a look at this question for a further insight about this subject.

Ahmed Shaqanbi
  • 525
  • 5
  • 15