当前位置:网站首页>Principle and Technology of Virtual Memory
Principle and Technology of Virtual Memory
2022-08-05 02:46:00 【rainbow_lucky0106】
"Virtual memory" (virtual paging storage management scheme): a technical way of memory management that uses a portion of the hard disk space as a computer when the physical memory of the computer is not enough.memory to use.Virtual memory, as the name suggests, is a imaginary memory address space.
Principle: It is divided into multiple physical memory fragments, and some are temporarily stored on external disk storage for data exchange when needed.
How it works
The principle of program execution
The operating system gives each process the illusion that it has its own large amount of private memory, which can have a large contiguous address space to put its own code and data.The addresses accessed in the user program are virtual addresses, which need to be translated into physical addresses through the cooperative work of the operating system and the hardware to find the desired information.
Modern computer systems are equipped with high-speed random-access memory, called main memory, physical memory, or simply memory.Memory is the hardware used to store code and data. It is directly addressable storage space by the processor and fast access rate.The host entity of memory is usually Random Access Memory (RAM), and CPU can directly exchange data with RAM.In the working state of RAM, information can be written (stored) or read (taken out) from any specified address at any time.
The CPU usually generates a virtual address (VA) to access the main memory. Before this virtual address is loaded into the memory, it needs to look up the table and convert it into a physical address (PA), and finally the CPU indirectly accesses it.This physical address (PA) of memory.
Before the program is executed, it needs to be put in memory before it can be processed by the CPU.
When the program runs, it copies the program saved on the hard disk to RAM memory (load memory), and then CPU executes the program code in memory.Out of memory is caused by executing a program that uses a large or large amount of memory, or executing multiple programs at the same time.As a result, the program executes abnormally or crashes.
How virtual memory works
The address space of a process at runtime is actually a layer of logically abstracted contiguous addresses.When the process starts to run, a part of the program is loaded into the memory first, and the other part that does not need the actual physical memory temporarily stays in the external memory, and the actual physical memory is not allocated temporarily; when the instruction to be executed is not in the memory, and the system does the job of loading them into memory automatically.
(Memory Management: Automatic Swap Technology) When not enough memory, the system automatically selects part of the memory (programs not to be executed), and replaces the originalswapped to disk (hard disk) and frees the actual physical memory it occupies for use by other processes.The result of this is that the operation of the program is not affected at all, and the program feels that it has a virtual memory that is not constrained by memory capacity and can meet its own needs during operation.
- Page Replacement Algorithm: See "Operating System".
Virtual memory gives applications powerful capabilities, applications can create and destroy memory slices, applications can map memory slices to disk files, applications canShare memory with other processes.
Function
By running programs in lieu of some of the work of physical memory, the computer can run more programs and perform more tasks at the same time.
Virtual memory is not as simple as memory backup. In many cases, Win will use virtual memory to perform some specific operations to improve memory hit rate and system stability, especially for some memory-hungry ones.Software, such as Photoshop, 3Dmark, and some 3D games, also require virtual memory at runtime.
Disadvantages
But frequent swapping in and out is still a performance bottleneck.In order to reduce the impact of swapping in and out, increasing the available physical memory and increasing the access speed of external memory are two options.
Features
- Inexpensive, large capacity.Virtual memory is actually hard disk space, and the price of the same space is lower than that of physical memory.
- Inefficient operation.Hard disk transfers are much slower than memory transfers.
- Data loss after power outage.Like physical memory, after a sudden power failure, the data in virtual memory will be lost, and it does not have the function of saving hard disk (external memory) power failure.
System Space Settings
We can use the actual situation of the computer to continuously adjust and set the size of the virtual memory of the computer. If the setting is too small, it will not be enough. If the setting is too large, too many fragments will be generated, which will affect the running speed of the computer.
Recommendation: 1.5 to 3 times the actual physical memory of the computer.You can also let Windows automatically allocate and manage virtual memory, and it can dynamically adjust the size of virtual memory according to the actual memory usage.
How to set virtual memory in Win10?
How much virtual memory setting is appropriate for win10?This is the best setup!
边栏推荐
- undo problem
- RAID disk array
- 金仓数据库如何验证安装文件平台正确性
- The 20th day of the special assault version of the sword offer
- Optimizing the feed flow encountered obstacles, who helped Baidu break the "memory wall"?
- word分栏小记
- ARM Mailbox
- post-study program
- 解决connect: The requested address is not valid in its context
- C语言日记 9 if的3种语句
猜你喜欢
The design idea of DMicro, the Go microservice development framework
C语言日记 9 if的3种语句
倒计时 2 天|云原生 Meetup 广州站,等你来!
QT语言文件制作
[Decryption] Can the NFTs created by OpenSea for free appear in my wallet without being chained?
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
Matlab drawing 3
继承关系下构造方法的访问特点
lua学习
Data storage practice based on left-order traversal
随机推荐
从零到一快速学会三子棋
02 【开发服务器 资源模块】
Programmer's Tanabata Romantic Moment
人人都在说的数据中台,你需要关注的核心特点是什么?
Compressed storage of special matrices
How to solve the error cannot update secondary snapshot during a parallel operation when the PostgreSQL database uses navicat to open the table structure?
ARM Mailbox
1667. Fix names in tables
注意潍坊开具发票一般需要注意
torch.roll()
The problem of lack of dynamic library "libtinfo.so.5" in ksql application under UOS system
【OpenCV 图像处理2】:OpenCV 基础知识
Countdown to 2 days|Cloud native Meetup Guangzhou Station, waiting for you!
线上MySQL的自增id用尽怎么办?
HDU 1114:Piggy-Bank ← 完全背包问题
LeetCode使用最小花费爬楼梯----dp问题
02 [Development Server Resource Module]
nodeJs--encapsulate routing
链表的简单描述及代码的简单实现
private package