Does the computer erase the values which have been reserved for variables in the RAM after the program is finished?

Viewed 23

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?

1 Answers

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.

Related