Ask Leo!

What is Virtual Memory?

Home » General Computing

Summary: Virtual memory is conceptually somewhere between RAM and hard disk space; it's disk space used to maximize the amount of RAM available to programs.

What is Virtual Memory?

There's memory and then there's disk space. There's memory that's on disk, not to be confused with memory that looks like a disk. Disk that looks like memory? Isn't the disk a kind of memory? Or is it something else?

It very confusing, but we can clear a few things up. Disks and memory are fairly easy. Virtual memory is one way they overlap, and with a little explanation we can make that a little less confusing too.

First let's review the basics: Memory versus Disk Space.

When a computer geek like me (or a computer salesman not like me) talks about computer memory, or RAM (for Random Access Memory), we're talking about a bunch of silicon chips in your computer that hold things like the operating system, the programs you're actually running right now, the document currently shown in your word processor, or the email you're typing up. Computers these days typically have somewhere between 128 megabytes (128 million bytes) and 4 gigabytes (4 billion bytes). What's important is that when you turn the computer off or if it crashes - *poof* - anything stored in RAM is gone. That's why when you're editing a document it's a good idea to save to disk often.

When we talk about disks, we're talking about the hard disk drives in your machine. Quite literally, a hard disk drive is typically made of several metal disks coated with a magnetic material not unlike a video or audio tape, or the strip on the back of a credit card. The disk spins at a fairly high rate of speed, and special "heads" can read, or record, a pattern of bits (1's and 0's) on the magnetic surface. The operating system assembles those bits into bytes, and the bytes into the files you might save, receive, or create. Disks do not lose what's on them when you turn off the power. Typical disk sizes these days start in the 20 to 40 gigabyte range and go as high as 250 gigabytes. It won't be long before we see the next step, the terabyte (one trillion bytes), on a single disk.

Compared to memory disks are much slower. Too slow in fact for your computer to work from directly. So the typical sequence of events is to load your program or document into memory from disk, have it run or be worked on in memory, and then either remove it from memory if it hasn't changed, or save any updates back to the disk.

Virtual Memory is simply the operating system using some amount of disk space as if it were real memory.

Exactly how virtual memory is implemented is complex and well beyond what I'd want to present here. But in an over-simplified nutshell it works like this:

  • You run programs that need memory. The operating system takes care of tracking which program is using what portions of memory, and allocating each program the amount of memory it needs.

  • Those programs will need more memory as they do their jobs. Opening a large document may cause your word processor to request additional memory from the operating system in order to hold the document.

  • If there isn't enough memory available to satisfy a request, the operating system may decide that another program's needs are less "important". Some of that program's memory will be freed, first by writing the contents to disk (the memory is "swapped out"), and then allocated to the program making the request.

  • Later when the program whose memory was swapped out needs it back, that memory can be "swapped in" by reading it back from disk. This might cause memory from another program to be swapped out to make room.

Also remember that the operating system itself is also just a program. So it too will have need for memory. It can allocate memery to itself and its memory may get swapped out to disk as other needs arise.

As I said, disks are slower than memory, so if the operating system is doing a lot of swapping between the two it's going to slow your computer down. If that's happening frequently or if your computer seems to be "thrashing" or constantly swapping in and out from disk, then it might be time to add some memory to your machine. It can be one of the most cost effective ways to increase your system's speed.

Related:

More articles about: General Computing

Article Useful? Link to it from your own website; just copy/paste this HTML:

Article 183 | Posted April 14, 2004

Recent Comments

Oh yea and the graphics card iam using is the nvidia geforce 6600 gt apg 128 mb

Posted by: PERSON at January 19, 2006 04:13 PM

Hey Leo,

I have about the same question as Jason. I was wondering if there was any way at all to get more MB of RAM. Because I've heard somewhere that you can somehow "tweak" your computer to get more, but I'm a bit skeptical about it. My computer only has 124 MB of RAM. Some of my games require a lot more that this. I meet all the other requirements but it's the RAM that kills me.

If you're truly sure that there is no way to increase it the way it is please say so. Other than me going out and buying things to increase it, is there any other options to increase it?

Posted by: blue at February 5, 2006 10:20 PM

hi Leo,
I seem to have malware in my virtual memory and i have tried various programs to remove it, the best has been ewido,it recognizes it but there is an error during cleaning. I was wondering if you might know of any other programs that might be able to specifically target malware in virtual memory

Regards Josh

Posted by: Josh birchall at April 20, 2006 11:08 AM

Great !!...............You said it in terms that i could understand.
Thank you....Barbara

Posted by: Barbara at May 2, 2006 06:16 PM

please help me .
i want program(code) for virtual memory using programming language .
please send me quickly.
thank you very much.

Posted by: roqaya at May 14, 2006 04:34 AM

LEO,
I HAVE AN OS 2000NT AND RUNNING BIG PROGRAMS ON LINE,I AM RECEIVING THE LOW VIRTUAL MEMORY MESSAGE WHEN WORKING AT ON-LINE TRAINING.I HAVE TRIED TO INCREASE MY PC'S VIRTUAL MEMORY BY GOING THROUGH THE PERFORMANCE SETTING, BUT EVERY TIME I CHANGED MY INITIAL AND MAXIMUM SIZE, THE CHANGES DID NOT TAKE EFFECT EVEN THOUGH MY C DRIVE SPACE AVAILABLE IS 10003MB.PLEASE ADVISE ME AS SOON AS YOU CAN. I MUST ADD THAT, MY CURRENT REGISTERY SIZE IS 18MB AND MY MAXIMUM REGISTERY SIZE IS 35MB ONPAGING FILE SIZE FOR SELECTIVE DRIVE C.

THANKS
DR. MARANDI

Posted by: DR. MARANDI at August 1, 2006 09:27 PM

Leo,

If I increase my RAM, will I then be able to increase my virtual memory? I am trying to save a large movie file to a CD, evertime I get just about to the end of the movie the message increasing virtual memory comes up, my CD will finish, however just the music portion of my movie finishes and some of the pictures at the end are lost.

Thanks,

LT

Posted by: LT at August 21, 2006 12:54 PM

how is paging related to virtual memory

Posted by: viswanathan at April 9, 2007 10:19 AM

my ques.
pls give me some detail of virtual memory?
give the ans img.

Posted by: salil at April 28, 2008 09:55 PM

can we save something on virtual memory

Posted by: dipti at June 19, 2008 07:07 AM

Post a comment on "What is Virtual Memory?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!


New!

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

Please wait. Your comment is being processed ...


Ask Your Question:


ask-leo.com
Web

Archives

By Category
By Date

Advertisers

Advertise on Ask Leo!

««   »»

Question? - Ask Leo!
Who is Leo?
Link to Leo!

Terms, Conditions & Privacy