Relation Between virtual memory, cache memory and RAM?

pts.
Tags:
Cabling
Data analysis
Data Junction
Data Mining
Data warehousing applications
DataCenter
Hardware
Hubs
Microprocessors
Microsoft Windows
Networking
Routers
Switches
Systems management software
Hi friends, Hope you all are doing fine. Actually, I am new in the networking field. Can anybody tell me the size relation between virtual, cache and RAM memory in Windows Operating systems? Thanks in advance.

Answer Wiki

Thanks. We'll let you know when a new response is added.

The relationship between the various memory types in Windows Operating Systems (OS) are as follows.

The size relationship is (in general) from smallest to to largest: Cache – RAM – Virtual

RAM – Physical memory installed in the system. This is where most processing takes place. The maximum memory depends on hardware and OS version. The physical restriction on amount of RAM is the physical hardware limitation on how much RAM can be installed. This can be further restricted by the OS.

For OS versions that are 32-bit the available address space is 4 GB. This 4 GB address space is used for accessing the hardware as well as the memory. Thus the maximum memory the OS can use is the address space left over after that used for the hardware. Generally between 2.8 GB and 3.3 GB of the 4 GB address space is usable for the RAM. This is why you see less than 4 GB of RAM available even though 4 GB of RAM is installed for a 32-bit OS. (There are some special exceptions to this but that is beyond this explanation.)

For OS versions that are 64-bit they have an address (18,446,744,073,709,551,616 [2^64] bits) larger than today’s hardware can address. Due to the hardware limitations the current maximum memory that can be addressed is much smaller on the order of 256 TB (256 × 1024^4 bytes) which is orders of magnitude greater that can be physically installed in systems (even including virtual memory on hard disks). However some OS versions are artificially limited in the amount of RAM they will address which can limit your available RAM.

Cache memory – This encompasses a large range of items.
– Processors have multiple cache memory types usually referred to as level 1, 2 or 3. Processors can have all three types. These are used to speed up processor operations.
– Hard drives can have cache memory to speed up data transfers. Most modern hard drives have some on board cache.
– Hard drive controllers can have cache memory. This is usually found in SCSI, SAS or SATA RAID controllers.
– Network Cards can also have cache memory for high throughput cards generally found on some servers and some gaming systems.

Virtual memory is just that, virtual not the physical RAM.
– Virtual memory in a Windows OS is usually referring to memory that has been temporarily moved (paged out) from RAM to a hard drive or flash memory.
– Virtual memory can have other connotations when used with a hyper-visor such as Microsoft’s Hyper-V or VMWare’s ESX/ESXi (vSphere). In this case the hyper-visor manages all memory virtualizing it and assigning it to the virtual machines.
– Some systems or OSs can set aside pools of physical memory to use as virtual memory for specific tasks.

Discuss This Question: 11  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Poppaman2
    As you probably know, physical memory (RAM) is a fixed quantity (you add or remove memory depending upon your computers' requirements). Cache memory is also physical memory, but is normally associated with a specific device (as opposed to the O/S in general) such as a CPU, SCSI host bus adapter, RAID controller or Hard Drive. Except in the case certain devices such as mid- and high-range SCSI HBA's and RAID controllers, the cache memory is fixed; preinstalled at the time of manufacture. Cache RAM will usually (bot not always) allow a given system to function faster as it will accept data to be written, transferred or processed and hold it (cache it) at a much higher speed than what can be obtained from the target device. In the case of processor cache, it will hold data pending completion of other operations which will require the held data or in anticipation of it's use (pre-fetch cache) Virtual memory is an area of your disk (either logical or physical) which the operating system uses like physical RAM (it actually sees no difference between the two). Of course, this virtual memory, being an area on your hard drive is substantially slower than physical memory (speeds measured in milliseconds, as opposed to nanoseconds). Usually set to 1.5 - 2.0 times physical memory (and it's a good idea to define the virtual memory or swap file as having a fixed size (min size = max size = 1.5 - 2.0 times physical memory), this swap file CAN be eliminated in certain situations where extreme speeds are desired and there is enough physical memory in place. For example: A Database Server may have a 0mb swap file (no virtual memory) but contain 2GB - 4GB of memory (or more) per processor. A Graphics Design workstation running Photoshop may have a 0mb swap file because Photoshop uses it's own virtual memory system. Determining or "tuning" the size of a swap file is very task dependent and will vary from server to server depending upon the processor speed, physical RAM and the purpose for which the server will be used.
    0 pointsBadges:
    report
  • FrozenPort
    Viritual Memory (or a PageFile) is a section of hard disk space that serves like ram RAM (random access memory) is the physical on your mother board virtual memory takes most of the load off the physical memory when the physical memory buffer is either busy or overloaded. i'm not sure what the cache relationship is.
    0 pointsBadges:
    report
  • Solutions1
    With respect to what you term "size relation," a rule of thumb is that at each level the cache should exhibit a 90% or greater "hit rate." That is, L1 cache should fulfill >90% of requests and pass the rest to L2 Cache, which fulfills >90% or more requests, and passes the rest to main memory, which fulfills 90% or more, and passes the remainder to disk-based cache, which fulfills 90% and passes on the rest to non-cached file system/database reads. Overall, what is needed is balance. As physical capabilities and $ per unit of performance change, you need to rebalance. For example, new PCs and servers typically have bigger L1 and L2 cache than older ones, so you may need to expand memory and disk caches to stay in balance. Also, from a data base performance perspective, some predictable percentage of a given database needs to be cached at the disk level (e.g., 10%), so as a data base gets bigger, caching capability should expand at each leel to maintain balance and throughput. Therefore what is critical is to have effective performance measurements and diagnosis, and not only of cache utilization. For example, some processes are computationally constrained rather than data constrained, in which case adding more cache is irrelevant.
    0 pointsBadges:
    report
  • Segun
    explain the relationship beween primary memory to vitual memory
    10 pointsBadges:
    report
  • Darklinx
    As was mentioned before, Primary RAM is the physical sticks in the computer used to run your programs. Virtual memory is space allocated on the hard drive for use LIKE RAM. Theoretically you should have at least 1.5 times the space in virtual memory than physical. With regard to CPU cache, L2 is used to store anticipated instructions for the CPU, and the L1 is to store the immediate instructions. So the L1 cache will setup all instructions for processing by the CPU and the cache controller will fetch instructions from RAM and fill the L2 cache in prediction for what will be needed in L1 after the next instruction is put to the processor. Conversely, any memory used on hard drives or RAID controllers is called a buffer, because it's used to store data to be written. Cache memory isn't used to write to anything.
    75 pointsBadges:
    report
  • Chippy088
    Virtual RAM, or page file or swap file, (different names, same thing) is located on the hard drive, and is flexible in it's size. It is normally initialized, as Darklinx says, at about 1.5 times the physical ram installed,(depending on OS and/or manual settings) it could be more. It will increase if several memory hungry applications are loaded. To see what virtual memory you are using, launch task manager and have a look. Run it when you start the pc and look at the swap file usage, then load some programs and look at the figures again. You will see the difference in the size if you are running something memory grabbing, like excel or a graphics based application.
    4,625 pointsBadges:
    report
  • CRuNcHiEgEeK
    RAM is just a generic reference to physical memory in a computer. All memory in most modern operating systems is virtual memory. You'd be hard pressed to find a computer that allows applications to access physical memory directly. Different OS have different ways to grant and allocate memory requests but they all pretty much boil down to an API call. If granted, what you really get is an address range. Depending on the OS memory management design and state of the system at the time, your grant may be fully backed by physical RAM or partly by physical RAM, partly by the page file. In other words, virtual memory is not your page file, some place on the disk, etc... Page files or the likes are sometimes called virtual RAM because they use disk files to emulate the role of RAM. None of that matters in most applications as they all appear as virtual memory to the application. Cache is just another term that refers to transient storage for data/binaries that you will or might need soon. The purpose is to improve performance. For example, RAM is a cache for physical disks. Many application perform read ahead operations to pre-fetch data the OS think you will likely need based on current/previous patterns. Since RAM access can be up to 10,000 times faster than a basic disk, pre-fetching the data while you're working with the current data can significantly improve user experience. Other more specialized forms of cache can be physical memory chips for specific tasks. This includes regular hard disks (yes, many new ones have built in caches), CPU, storage controller cards, etc... Their physical specs may be very different from traditional RAM but they still serve the same purpose. Btw, the post about percentages in L1 and L2 caches in CPUs (...should fulfill >90% of requests, etc.....) is completely incorrect. That's not how CPU caches are used and it is not the right way to think about CPU caches. At a very high level, CPU caches are small, high speed memory that fronts regular RAM and for CPU instructions. Cache hit ratios are generally not meaningful here, at least not in the say @solutions1 described.
    20 pointsBadges:
    report
  • Chippy088
    @CHruNcHieGeEk not a bad first post, riddled with inconsistencies, but interesting. I am guessing you are newly qualified to the technology. I say that because most of your comments are general and unsupported. "RAM is just a generic reference to physical memory in a computer." "RAM is a specific definition of a type of memory." Random Access Memory, denoting it does not have to be read sequentially. (any bit or byte can be read and changed in any order, if you are capable of low level programming.) There is also a ROM type of memory. Some of the logic chips on the motherboard are this type. "All memory in most modern operating systems is virtual memory." Strange statement. If it is truely virtual, it will not exist except in ones imagination. It has to have a physical presence. The Virtual in this case refers to the fact that the application is not really aware of how much physical memory it is running in, because it does not controll the virtual environment. That is what the OS does. APIs assist programmers to save "re-inventing the wheel", and cut down the size of the application. The actual postee was requesting some form of co-relation between the memory storage methods. Although you trashed a mention of cache prioritisation, you didn't provide any form of reasoning behind your statement, and definately didn't assist in providing a relevant answer.
    4,625 pointsBadges:
    report
  • Kccrosser
    (I know some of this has already been stated, but it seems like some clarification is still warranted.) RAM is Random Access Memory. This is PHYSICAL memory in which it is possible to individually address and read/write the smallest memory storage unit (generally an 8-bit byte in most systems, but it may be a 16-bit or even 32-bit "word"). "Cache" covers a lot of different storage. I assume from the original question that this refers specifically to the L1/L2 (and now L3) types of cache in a personal computer. These caches are generally physically embedded in the CPU chips in the computer for speed of access, and are used to hold recently referenced information, and also to hold "future" instruction and data information (aka a "pipeline cache"). Virtual Memory is any memory area that appears to the application software as real physical memory, but which may be relocated dynamically in the RAM memory or even temporarily stored on secondary (i.e., disk) storage. The size of the L1/L2/L3 cache memory is generally fixed for a given CPU. In the Intel i7-2620M CPU, the processor includes 4 Megabytes of on-chip "Smart Cache" (they no longer distinguish L1/L2/L3 sizes individually). Maximum RAM is usually a function of the physical capacity of the box containing the computer. Laptops may only hold 8 GB, while servers can hold 256 GB or more. Virtual Memory is usually configured as 1.5x to 2.5x the size of the physical (RAM) memory in the system, but that ratio can vary widely. So - a typical home or laptop computer might have the following configuration: RAM - 4 GB CPU Cache - 2 MB Virtual Memory - 5-6 GB Servers are a bit trickier, as almost all current servers use multiple CPUs, with each CPU including its on-chip cache memory. A 4-CPU server might have: RAM - 64 GB CPU Cache - 16 MB (4 MB per CPU) Virtual Memory - 96-128 GB
    3,830 pointsBadges:
    report
  • TomLiotta
    Servers are a bit trickier... And for IBM i systems (essentially the entire line beginning with the System/38 up to AS/400s and later), it's really tricky. Applications and the OS see everything as a "single-level store" model. Effectively, all RAM and disk is accessed as an address range for memory. All addressable objects are seen as being "in memory". The OS itself has no concept of a disk unit -- it's the VM that everything runs on top of that effects address translation into disk units and sectors. "Virtual memory" is the size of available DASD in the system storage pool of disk drives. Tom
    125,585 pointsBadges:
    report
  • CRuNcHiEgEeK
    @Chippy008 I used to work on the buffer pool manager and resource manager for an enterprise database. I stand by what I said. I thought I explained what each part does pretty clearly. I also pointed out a incorrect statements; I don't see why that would be considered thrashing. As for the OP question, it was about size relationship between virtual memory, cache memory and RAM; I don't see any mention of storage methods. Your statement about the application being not really aware of how much physical memory it is running in, because it does not controll the virtual environment is also inaccurate. Applications can control whether its VM allocation is maintain strictly in RAM or if it will allow Windows to page it out to disk (other OS'es have similar capabilities). Feel free to verify this yourself and see how VirtualAlloc is used in "regular" allocations and how it works with AllocateUserPhysicalPages when you need to lock it in physical memory. You'll also need to map the two but I'm guessing you already know Win32 API functions for those.
    20 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following