Instructor: In this lesson,
we're going to talk about virtual memory.
Virtual memory, also known as a page file,
is essentially a block
of space on your hard drive or solid state drive
that's allocated by your operating system
and pretends to be memory,
or RAM, when your physical RAM is running short
or low for your actively running programs.
Now, this is a great feature
from most modern operating systems
that allows you to basically emulate
that you have more memory
than you really do.
But keep in mind,
this is not a perfect fix for all solutions,
and it really is more of a temporary solution for you,
and if you're running into a lot of uses of virtual RAM,
you're probably going to need to increase your physical RAM
on the system as well.
Now, why is that?
Well, remember,
when we're dealing with the different types
of memory and storage, we have three main types.
We have cache memory inside the processor
that's extremely fast.
Then we have our physical random access memory,
or system memory,
and that RAM is slower than cache,
but it is still way faster than using a storage device,
like a hard disk drive or even a faster solid state drive.
When it comes down to it, there is no real replacement
for physical memory, but in a pinch,
virtual RAM can be used.
Now, when it comes to virtual RAM or virtual memory
as we often call it,
there's really two types that you'll see.
If you're running on a Windows system,
you'll hear this referred to as a page file.
If you're running a Linux, Unix or Mac system,
this is usually referred to as swap space.
Both of these mean the exact same thing.
It's essentially a hidden file
on your storage device that will increase in size
and pretend to be system memory for you.
So as your physical system memory runs out,
data will be transferred from that physical memory
into that page file or swap space,
and it will pretend that you have more memory than you do.
Now, a clear sign
that you're relying too much on your virtual memory
is when you start hearing your hard drive turning
a lot while you're working on different programs.
This is because things are being swapped
into and out of that page file
or swap space and back into RAM.
And every time that happens,
it has to read and write that from the hard drive,
which slows down your entire system
and all of your other processes.
When you're dealing with virtual memory,
your operating system is going
to assign these memory locations
to these different processes
in chunks that are four kilobytes in size.
These chunks are known as pages.
Now, the memory controller is going to be able
to move things into or out of physical memory
by using these four kilobyte chunks or pages,
and this actually frees up more of your physical memory.
But remember, the CPU in your system can't read directly
from the hard drive like it can from memory using its bus,
and therefore, that stuff is going to have to be paged in
and out of memory from the swap file
or page file so that you can then use it.
If you start seeing your system slowing down a lot,
remember, it's probably going to be a memory issue,
so check your available memory
and how much free memory you have.
And if you don't have a lot, that may be time
for you to put more additional physical memory in.
But in the meantime, you can increase the size
of your virtual memory or page file,
or swap space to be able to hold a little bit more
and trick your system into thinking it has more memory
than it really does as an intermediate solution
until that physical RAM module can be installed later on.