- Expert C++
- Vardan Grigoryan Shunguang Wu
- 330字
- 2021-06-24 16:33:57
Virtual memory
The memory consists of lots of boxes, each of which is able to store a specified amount of data. We will refer to these boxes as memory cells, considering that each cell can store 1 byte representing 8 bits. Each memory cell is unique even if they store the same value. The uniqueness is achieved by addressing the cells so that each cell has its unique address in the memory. The first cell has the address 0, the second cell 1, and so on.
The following diagram illustrates an excerpt of the memory, each cell with its unique address and ability to store 1 byte of data:
The preceding diagram can be used to abstractly represent both physical and virtual memories. The point of having an additional layer of abstraction is the ease of managing processes and providing more functionality than with physical memory. For example, OSes can execute programs greater than physical memory. Take a computer game as an example of a program taking almost 2 GB of space and a computer with a physical memory of 512 MB. Virtual memory allows the OS to load the program portion by portion by unloading old parts from the physical memory and mapping new parts.
Virtual memory also better supports having more than one program in memory, thus supporting parallel (or pseudo-parallel) execution of multiple programs. This also provides efficient use of shared code and data, such as dynamic libraries. Whenever two different programs require the same library to work with, the single instance of the library could exist in memory and be used by both programs without them knowing about each other. Take a look at the following diagram, which depicts three programs loaded into memory:
There are three running programs in the preceding diagram; each of the programs takes up some space in virtual memory. My Program is fully contained in the physical memory while the Calculator and Text Editor are partially mapped to it.
- HTML5+CSS3王者歸來
- JavaScript全程指南
- 微信公眾平臺開發:從零基礎到ThinkPHP5高性能框架實踐
- INSTANT Django 1.5 Application Development Starter
- 飛槳PaddlePaddle深度學習實戰
- Kotlin編程實戰:創建優雅、富于表現力和高性能的JVM與Android應用程序
- Express Web Application Development
- 青少年信息學競賽
- Python Data Structures and Algorithms
- C語言程序設計簡明教程:Qt實戰
- 測試架構師修煉之道:從測試工程師到測試架構師
- Visual C++程序設計與項目實踐
- Python編程基礎教程
- HTML5游戲開發實戰
- C語言王者歸來