What is virtual memory and how is it different than RAM?

354 views

What is virtual memory and how is it different than RAM?

In: 41

11 Answers

Anonymous 0 Comments

Virtual memory is a mechanism in the central processor operating in protected mode that allows each program to have access to a continuous region of memory as if it was running alone on the system. The operating system maps blocks of actual memory into this virtual addressing system. It also enables unloading blocks of memory to disk temporarily. In casual conversation these paging files are sometimes called virtual memory.

Anonymous 0 Comments

Most/all modern systems have a piece of hardware in the CPU that lists what memory address ranges in RAM a program is allowed to access, what the *actual* RAM location is, and what the rules are (eg: read-only areas, no-code areas, etc). The operating system loads it with a table of memory allowed by the currently running program, and the program runs by constantly replacing memory addresses the program thinks it uses with actual RAM locations from this table. This is done by the hardware, and programs aren’t aware of it happening. Violations, by either trying to access memory not listed, or violating the rules assigned, will stop the program and the operating system will intervene.

When which program is running changes, the table contents are swapped out for one appropriate to the newly running program. There’s even a table for the operating system itself.

Normally not having an entry in the table, or breaking a rule, will crash the program. However the operating system can *intentionally* leave out entries or tighten up their rules just so that the hardware will inform it when memory is accessed. Memory that has been swapped out of RAM and saved to disk can be loaded back into RAM when the program tries to access it. A single copy of memory can be shared among multiple programs as long as it is read-only; if a program tries to write to it, we can duplicate the memory region and make it writeable after the fact, preserving the original for all other running programs using it.

RAM is a real thing, and all programs need it. Virtual Memory is this table, gatekeeping the RAM, protecting memory that doesn’t belong to you, and also protecting you from other programs.

Anonymous 0 Comments

If a process needs more memory than than the RAM that’s available on the computer, “virtual memory” steps in. Virtual memory is the usage of storage space as memory. It’s a lot slower than RAM, but it gets the job done.

Anonymous 0 Comments

**Virtual memory** is a part of your hard drive that acts like extra RAM when your computer runs out of it. **RAM** is a physical memory that holds the applications and data that you are using on your computer. RAM is faster than virtual memory, but it is also more expensive and limited in size.

Anonymous 0 Comments

Virtual memory means two things depending on who’s asking:

It means the operating system swaps out what’s in RAM and what’s on disk when programs aren’t looking, when to hopefully make better use of your RAM. This is what it means when Microsoft says it.

Or, it means the CPU checks a big table of memory regions, to see whether the memory has been moved somewhere else or the OS needs to get involved, every single time it accesses memory. This is what it means when Intel says it. This feature allows Microsoft to do the disk swappy thing, but it also enables a bunch of other stuff that’s taken for granted, like protecting one program from bugs in another program by making sure only that program’s memory is allowed to be accessed when it’s running.

Anonymous 0 Comments

Don’t see too many ELI5 answers here. Here’s a stab at it:

RAM is your computer’s physical memory. When a program runs on your computer the operating system tells it that it can use all the memory it wants. So a program can write or read from a memory address and not worry about it being reserved for other programs.

In reality lots of programs are running and competing for memory space. The addresses each program gets to use are called virtual memory because they don’t relate to a real physical memory address. The operating system decides where to direct the virtual addresses to real physical addresses to keep programs from interfering with each other.

Anonymous 0 Comments

Most of your computer is just different layers of data storage. These layers are physically further from your CPU, and thus slower. The RAM is relatively close to the CPU and thus is quite fast.

Your HD (or SSD) is not only much further physically from the CPU, but due to the technology behind the HD storage, it is orders of magnitude slower than RAM.

Virtual memory, is just a method of pushing system memory, from the very quick RAM to the slower HD, which has pros and cons, HDs are larger and cheaper, but you lose a lot of performance, to name a few.

Anonymous 0 Comments

When I go to my local sports arena to watch American football, the groundskeepers prepare everything beforehand. They spend days laying turf in the proper areas, setting up goalposts, etc. When I get there, it looks like a football stadium.

Three days later, there is a rock concert there. The groundskeepers roll up the turf, and disasseble the goalposts. Then they build a stage, and add a bunch of bleachers. When the music fans come it, it is a music venue.

The next week, there is a baseball game. The groundskeepers disassemble the stage, take down most of the bleachers, and bring out the rolls of turf. They assemble a dugout and a batter’s cage. When the baseball fans come in, they see a baseball stadium.

In all events, it is the same place. Every event uses the same field. Their fans use the same parking places. But for a short perod of time, it is customised for a particular user.

When that user comes back a seond time, it will look like nothing changed since their previous visit. To them, it is always a place that hosts their event. Lost of other events may have happened in the intervening time, but they don’t see that.

There are huge storage places underneath much of the seating. The groundskeeper may even rent a local warehouse to store stuff when not in use.

Anonymous 0 Comments

RAM is an acronym for Random Access Memory. This is a region on a computer that has several pins that can have voltages on them (8GB or RAM means there are 2^26 of those pins) data has to be loaded into RAM before you can run an operation on it. Loading data from the hard drive into RAM is very slow compared to how quickly the operations run.

Data is constantly being loaded into RAM as the computer runs its programs, but sometimes, a piece of data will need to be in RAM (because it needs to be in RAM to be used at all) but it doesn’t get used often, so it doesn’t need to be sitting ready in RAM because speed isn’t that important for this piece of data. Instead of properly saving it to the hard drive in a space reserved for the relevant software to be accessed later, it gets saved to a specific region of the hard drive called the virtual memory. When that piece of data needs to be loaded back into RAM, it is copied from the virtual memory, and whatever operation needs to be run can be. This still saves time because instead of having to search through the hard drive for the right location every time, it can search the region set aside for virtual memory, while leaving a safe region where that data can’t be overwritten.

Anonymous 0 Comments

Every application you run needs some amount of short-term storage space to store its working state. Every variable a program uses, every image or audio file it loads, every string of text it generates, is stored there, accessed by a unique numerical address. This short term storage space is called memory.

RAM is a physical component in your computer that can be used for memory. If that runs out, a storage disk (HDD or SSD) can be used for additional “virtual” RAM, but it’s much slower. The process of moving memory data from RAM to disk is called Paging or Swapping (the implementation details between the two are different, but that’s not important).

The operating system is in charge of allocated memory to an application. As an application runs, it asks the computer for a certain amount of memory space, or frees up some if it’s no longer needed. When an application runs, the OS presents to it an abstract, contiguous space of memory addresses unique to the program that comprises both the physical and virtual RAM.

The benefit of virtual memory is that:

1. the application doesn’t have to worry about where the data physically exists, the OS manages it
2. the OS can optimise resources by paging unused memory to disk
3. it segregates memory spaces for security, meaning one process generally can’t access the memory of another process (and accidentally corrupt it, or steal data)
4. it allows each program to access memory at a specific address without conflict, eg. two applications can store a variable at “memory address 0x004A” and there won’t be any issue since the underlying data is physically mapped to somewhere else, each program has its own memory mapping

Be aware that sometimes people use “virtual memory” to refer specifically to the virtual RAM component (disk space used as memory with swapping/paging techniques) rather than the higher concept of a virtual address space.