Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Propp
30 PointsClarify:The Ram communicates to hdd, as it communicates to CPU. When a program exits is it the cpus job to purge memory?
Hey, Im a bit confused. So the Ram communicates to the HDD, and the CPU communicates to the RAM. Ram stores the operating system as well as opened programs. Example: I click on word, it transfers to RAM, the cpu is recording my typing on keyboard onto the word doc. Is it the CPUs job to purge the memory of a closed program on the ram, or is it the rams itself job?
Thanks
4 Answers
Steven Parker
231,268 PointsThe job of dealing with the memory that was used by a program after it is closed falls on the operating system.
In fact, there is generally no actual "clearing" or "purging" taking place. The operating system is where the concept of whether a portion of RAM is "in use" or not exists. When a program is closed, the operating system just considers the RAM area the program was using as "free" again.
The RAM itself will likely remain unchanged and ignored until another program needs it.
Saurabh Arora
1,780 PointsThe memory management is done all by the operating system core component (the kernel). The kernel tracks down the usage of memory in all memory devices. When a process (or say app) opens, the kernel provide some pages (basic unit of memory) in the physical memory (RAM). When the process is closed the kernel frees the allocated memory pages in the RAM and then gives those free pages to a new process. Its the basic principle how the kernel manages memory. I can dive deep into this but I guess for this forum this information might be helpful.
Carlos José
Courses Plus Student 12,431 PointsThe OS is executed by the CPU which is loaded in RAM from the HDD/SSD by a Bootloader. Booting is what is called to the process of loading an OS. Actually the job of purging memory is done by the applications right now AFAIK. I haven't got to the subject to deeply but it is a security concern because some say that programs can read the values left in memory by other programs so special string Object have been implemented in some programming languages I think C# is one.
This values could be passwords and that is the main reason of security concerns I have read. In the early times of OS development there was not the broad internet as now so old traditional programming language didn't encounter this problem since the access to the computers where limited. And also transporting data was not so easy as it is now (in the case of direct access).
This should be the work of the OS but it can mean a cost in performance. A really good hacker I met told me that nowadays memory access is regulated in some ways by hardware (CPU), so that a program cannot see another's program data. But we didn't talk about "Used free" or Dirty memory.
We know RAM is volatile memory that clears out when the computer shuts down, so this has made unnecessary to implement memory flushing in software. Now we have computers that communicate to the outside world that don't shutdown when unattended and things get serious when important/classified data is stored in this computers.
I see two possibilities :
- Zero out the memory when programs exit.
- Zero out the memory when memory is assigned to programs before they can read it. Could help performance of the OS but maybe slow programs load time
Maybe the best solution is a HW based solution but the question raises, is that cost effective ?
Roberto Núñez
4,256 PointsAlmost all type of storage in a computer is permanent until one of two things happen, either you overwrite it with new info or you loose power. In the case of a hard drive the second is not an issue but for RAM it is. Having said that the only thing a computer has to do to "free" ram or hard drive space is go to a directory and mark that space as usable so next time it needs space it will automatically use that space and overwrite what was in it.