In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
, a virtual address space (VAS) or
address space
In computing, an address space defines a range of discrete addresses, each of which may correspond to a network host, peripheral device, disk sector, a memory cell or other logical or physical entity.
For software programs to save and retrieve ...
is the set of ranges of virtual addresses that an
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
makes available to a process. The range of virtual addresses usually starts at a low address and can extend to the highest address allowed by the computer's
instruction set architecture
In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, ...
and supported by the
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
's pointer size implementation, which can be 4
bytes
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
for
32-bit
In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in a maximum of 32- bit units. Compared to smaller bit widths, 32-bit computers can perform la ...
or 8
bytes
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
for
64-bit
In computer architecture, 64-bit integers, memory addresses, or other data units are those that are 64 bits wide. Also, 64-bit central processing units (CPU) and arithmetic logic units (ALU) are those that are based on processor registers, a ...
OS versions. This provides several benefits, one of which is security through
process isolation
Process isolation is a set of different hardware and software technologies designed to protect each process from other processes on the operating system. It does so by preventing process A from writing to process B.
Process isolation can be implem ...
assuming each process is given a separate
address space
In computing, an address space defines a range of discrete addresses, each of which may correspond to a network host, peripheral device, disk sector, a memory cell or other logical or physical entity.
For software programs to save and retrieve ...
.
Example
:''In the following description, the terminology used will be particular to the
Windows NT
Windows NT is a Proprietary software, proprietary Graphical user interface, graphical operating system produced by Microsoft as part of its Windows product line, the first version of which, Windows NT 3.1, was released on July 27, 1993. Original ...
operating system, but the concepts are applicable to other
virtual memory
In computing, virtual memory, or virtual storage, is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a ver ...
operating systems.''
When a new application on a
32-bit
In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in a maximum of 32- bit units. Compared to smaller bit widths, 32-bit computers can perform la ...
OS is executed, the process has a VAS: each one of the
memory address
In computing, a memory address is a reference to a specific memory location in memory used by both software and hardware. These addresses are fixed-length sequences of digits, typically displayed and handled as unsigned integers. This numeric ...
es (from 0 to 2
32 − 1) in that space can have a single byte as a value. Initially, none of them have values ('-' represents no value). Using or setting values in such a VAS would cause a
memory exception.
0 4 GiB
VAS , ----------------------------------------------,
Then the application's executable file is mapped into the VAS. Addresses in the process VAS are mapped to bytes in the exe file. The OS manages the mapping:
0 4 GiB
VAS , ---vvv----------------------------------------,
mapping , , ,
file bytes app
The v's are values from bytes in the
mapped file. Then, required
DLL files are mapped (this includes custom libraries as well as system ones such as
kernel32.dll
and
user32.dll
):
0 4 GiB
VAS , ---vvv--------vvvvvv---vvvv-------------------,
mapping , , , , , , , , , , , , ,
file bytes app kernel user
The process then starts executing bytes in the EXE file. However, the only way the process can use or set '-' values in its VAS is to ask the OS to map them to bytes from a file. A common way to use VAS memory in this way is to map it to the
page file
In computer operating systems, memory paging is a memory management scheme that allows the physical memory used by a program to be non-contiguous. This also helps avoid the problem of memory fragmentation and requiring compaction to reduce fra ...
. The page file is a single file, but multiple distinct sets of contiguous bytes can be mapped into a VAS:
0 4 GiB
VAS , ---vvv--------vvvvvv---vvvv----vv---v----vvv--,
mapping , , , , , , , , , , , , , , , , , , ,
file bytes app kernel user system_page_file
And different parts of the page file can map into the VAS of different processes:
0 4 GiB
VAS 1 , ---vvvv-------vvvvvv---vvvv----vv---v----vvv--,
mapping , , , , , , , , , , , , , , , , , , , ,
file bytes app1 app2 kernel user system_page_file
mapping , , , , , , , , , , , , , , , , ,
VAS 2 , --------vvvv--vvvvvv---vvvv-------vv---v------,
On
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
32-bit, by default, only are made available to processes for their own use. The other are used by the operating system. On later 32-bit editions of Microsoft Windows, it is possible to extend the user-mode virtual address space to while only is left for kernel-mode virtual address space by marking the programs as IMAGE_FILE_LARGE_ADDRESS_AWARE and enabling the switch in the boot.ini file.
On Microsoft Windows 64-bit, in a process running an executable that was linked with , the operating system artificially limits the user mode portion of the process's virtual address space to 2 GiB. This applies to both 32- and 64-bit executables. Processes running executables that were linked with the option, which is the default for 64-bit Visual Studio 2010 and later, have access to more than of virtual address space: up to for 32-bit executables, up to for 64-bit executables in Windows through Windows 8, and up to for 64-bit executables in Windows 8.1 and later.
Allocating memory via
C's
malloc
C dynamic memory allocation refers to performing manual memory management for dynamic memory allocation in the C programming language via a group of functions in the C standard library, namely , , , and .
The C++ programming language includ ...
establishes the
page file as the backing store for any new virtual address space. However, a process can also
explicitly map file bytes.
Linux
For
x86
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
CPUs,
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
32-bit allows splitting the user and kernel address ranges in different ways: ''3G/1G user/kernel'' (default), ''1G/3G user/kernel'' or ''2G/2G user/kernel''.
See also
*
Linear address space
Flat memory model or linear memory model refers to a memory addressing paradigm in which "memory appears to the program as a single contiguous address space." The CPU can directly (and linearly) address all of the available memory locations with ...
*
Single address space operating system
In computer science, a single address space operating system (or SASOS) is an operating system that provides only one globally shared address space for all processes. In a single address space operating system, numerically identical (virtual memor ...
Notes
References
* "Advanced Windows" by Jeffrey Richter, Microsoft Press
{{Data types
Virtual memory
de:Virtueller Adressraum