当前位置:网站首页>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!
边栏推荐
- mysql树状结构查询问题
- [ROS](10)ROS通信 —— 服务(Service)通信
- Open Source License Description LGPL
- C语言实现简单猜数字游戏
- Physical backup issues caused by soft links
- 倒计时 2 天|云原生 Meetup 广州站,等你来!
- 正则表达式,匹配中间的某一段字符串
- leetcode - symmetric binary tree
- 解决connect: The requested address is not valid in its context
- 02 [Development Server Resource Module]
猜你喜欢
VSCode Change Default Terminal 如何修改vscode的默认terminal
Cloud Native (32) | Introduction to Platform Storage System in Kubernetes
Matlab map with color representation module value size arrow
2022-08-04: Input: deduplicated array arr, the numbers in it only contain 0~9.limit, a number.Return: The maximum number that can be spelled out with arr if the requirement is smaller than limit.from
01 [Foreword Basic Use Core Concepts]
02 【开发服务器 资源模块】
Pisanix v0.2.0 released | Added support for dynamic read-write separation
数据增强Mixup原理与代码解读
C语言日记 9 if的3种语句
Multithreading (2)
随机推荐
[ROS] (10) ROS Communication - Service Communication
Syntax basics (variables, input and output, expressions and sequential statement completion)
语法基础(变量、输入输出、表达式与顺序语句)
C student management system Insert the student node at the specified location
Multithreading (2)
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
QT MV\MVC结构
The problem of lack of dynamic library "libtinfo.so.5" in ksql application under UOS system
1873. The special bonus calculation
甘特图来啦,项目管理神器,模板直接用
软链接引发的物理备份问题
tree table lookup
leetcode 15
线上MySQL的自增id用尽怎么办?
1484. 按日期分组销售产品
What should I do if the self-incrementing id of online MySQL is exhausted?
Data storage practice based on left-order traversal
倒计时 2 天|云原生 Meetup 广州站,等你来!
DAY23:命令执行&代码执行漏洞
VSCode Change Default Terminal how to modify the Default Terminal VSCode