3

I have a laptop of 1 GB RAM. When I did my schooling, my computer teacher said me that RAM is the workspace of any computer devices. Whenever I came across a computer book for beginners, I was able to see that statement printed inside. Only then I decided to take it up as a fact. Suddenly one day, when I was watching a movie in my lap I was too astonished. I was running a video file of size 2+GB inside a 1 GB RAM. "How could this be possible", I thought? If RAM is the workspace, how did it supported the video file? I was wondering for sometime. Then I was seeking answers for the mystery. Soon I found that a technology called virtual memory is responsible for doing those wonders.

I started learning about memory management in computers then. As far as I have read, virtual memory is nothing but the combination of RAM and the disc. If RAM gets filled completely then the free space of the disc will moreover be the acting RAM. This is what I have learnt. Even wikipedia says so. Virtual memory combines active RAM and inactive memory on the DASD to form a large range of contiguous addresses. If that is true, RAM can't be claimed as the workspace of a system. In that case, the workspace of a system is the virtual memory. Is it practically possible ?

I strongly believe that the definition in wikipedia is wrong. And I still believe that the RAM is the workspace of the system. This is because I think that RAM and DASD kind of varieties would've not been designed if truely the wiki-defined virtual memory is practically possible. If the virtual memory combines both the primary and secondary memory into one, then what is the purpose for they have been created. A single memory is actually enough on that view. That has not happened so far. So something more is happening in. That makes the RAM to be the workspace still and no such virtual memory is really existing. If it is not existing then why we have books and definitions on it?

Can somebody help me what really will be going inside the computer if a RAM gets filled completely?

5
  • 1
    A video that is larger than the total ram is not a great example, because in the case with video , the whole file is not really ever required to exist in memory. only enough to decode , de-compress re-assemble sections of it and display. Ram is still usually the workspace, even with virtual memory (using disk), because the systems try to keep the things they are working on at the moment in ram, and push other things not as nessisary at the moment to the disk. (as best as the programmer made it to do so)
    – Psycogeek
    Jun 25, 2014 at 5:33
  • Where exactly the non working things are kept in the disc ?
    – Ramvignesh
    Jun 25, 2014 at 5:36
  • 1
    In a windows system, the file location for faking ram on a disk is called "paging". And it most certannly can be used out of that file in very similar ways (although way slower) as the ram itself. Because all the memory is classed in these systems as Virtual memory , all parts of the virtual whole memory (confusing as it might be) They would probably say that Virtual memory is always the workspace, ram being one part of it. It is how the programming and systems were made, in another world or in another time it could have been different, or said different, that is just how they did it.
    – Psycogeek
    Jun 25, 2014 at 5:50
  • This literally is a one-word answer, which is a fundamental part of almost all virtual memory implementations: memory paging. "Memory" in a computer is just an array of binary information - where the CPU fetches this information from, whether it be CPU registers, CPU cache, system RAM, your hard drive (or another device) is irrelevant, especially in systems using memory-mapped I/O where each device in the computer exists in the virtual address space alongside the RAM itself. Jun 30, 2014 at 15:42
  • 1
    Good question. You got a very bright future!
    – Prasanna
    Oct 12, 2014 at 11:20

1 Answer 1

4

The RAM being filled completely is the normal state of a modern computer with a modern operating system. RAM not filled is wasted -- it's not like you can save it for later.

The operating system makes a judgment about how best to use the RAM to provide the best performance. Accessing information in RAM is faster than accessing information on disk or elsewhere, so the memory manager tries its best to keep the "working set" (information the workload accesses a lot) in RAM.

Typically, information that the workload tries to access is pulled into RAM if it's not there already. The operating system then tries to keep in RAM the information that is accessed the most frequently to provide the best possible performance. RAM is the workspace.

Virtual memory permits the application-level code to not care whether the information it operates on is resident in RAM or not. The operating system can evict information from memory based on its best estimates of what will impact performance the least and the missing information can be "faulted into RAM" as the workload needs it.

9
  • So what exactly a virtual memory is?
    – Ramvignesh
    Jun 25, 2014 at 5:31
  • 1
    It's RAM on your HDD, which is much slower. In perfect conditions this would be empty (at least using Linux, not sure about Windows). However, if your RAM is (almost) completely filled (with the real data, not cache), the OS decides to move the less important stuff to your virtual memory (usually this would be large blocks of data that are not accesed frequently). Windows uses a file to store the virtual memory, Linux uses a special partition (but it's also possible to use a file). Jun 25, 2014 at 7:20
  • 1
    By default Windows calculates the best size of your virtual RAM. You can set it manually in Control Panel > System > Advanced system settings > Advanced > Performance > Settings... > Advanced > Virtual memory > Change.... For Linux you would just resize your swap partition or file. Jun 25, 2014 at 12:19
  • 3
    @LouisMatthijssen Virtual memory is not RAM on your HDD. There are systems with virtual memory and no hard drives. This is a common misconception. You are confusing virtual memory with paging. Jun 25, 2014 at 18:37
  • 1
    @LouisMatthijssen Unless you consider the perfect conditions to be infinite RAM, linux for example will also swap on perfect conditions. On default settings, it will prefer to swap out some unused application data and instead hold more filesystem cache. This is generally desirable for servers, not so on desktops. Oct 12, 2014 at 11:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .