You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求分页术语澄清:Frame定义与虚拟地址空间分配问题咨询

Answers to Your Demand Paging Questions

Great questions—demand paging and memory virtualization can feel confusing at first, so let's unpack each part clearly:

What is a Frame?

  • First off, a Frame (physical page frame) is a fixed-size block of physical RAM (not disk storage). Its size exactly matches the size of a "Page" in virtual memory—this 1:1 size match is intentional, because it lets the MMU (Memory Management Unit) easily map virtual pages to physical frames.
  • To answer your follow-up: a frame can only hold one page, no more, no less. The entire point of the page/frame system is to create a uniform, manageable unit for memory mapping and swapping.
  • Remember: disk is used for swap space (virtual memory backing store), not as physical memory. When RAM runs low, the OS moves unused pages from RAM frames to disk swap, then fetches them back into a frame when the process needs them again—that's the core of demand paging.

Virtual Address Space in 32-bit Systems

Let's tackle your questions here one by one:

How is the 4GiB virtual address space allocated?

In 32-bit systems, every single process (application) gets its own, fully independent 4GiB virtual address space. This is memory virtualization at work—each process thinks it has exclusive access to the entire 4GiB range. When the OS switches between processes, it updates the MMU's page tables to point to the physical frames (or swap space) belonging to the new process, effectively "switching" which virtual address map is active. The old process's virtual address space isn't visible to the new one, which is how processes are isolated from each other.

How much virtual memory does each app get?

  • The theoretical maximum is 4GiB, but in practice, OSes reserve a chunk of that space for the kernel (for example, Windows defaults to 2GiB kernel / 2GiB user space; Linux can be configured to 1GiB kernel / 3GiB user space). So a user application will typically have 2-3GiB of usable virtual address space.
  • Also, the actual amount of virtual memory you can use (not just reserve) depends on the total of your physical RAM plus swap space. You can't use more virtual memory than your system has backing storage (RAM + swap) to support it.

What happens when an app needs more virtual memory?

  1. First, virtual address reservation: The OS will let the process reserve more virtual address space (this is just bookkeeping, no physical memory is used yet).
  2. On-demand page allocation: When the process actually tries to access that new virtual memory, the OS will look for a free frame in RAM to map the page to.
  3. Page swapping if RAM is full: If there are no free frames, the OS uses a page replacement algorithm (like LRU, "Least Recently Used") to find a page in RAM that hasn't been accessed in a while, writes it to disk swap space, frees up its frame, and then maps the new page to that frame.
  4. Out-of-Memory (OOM) scenario: If swap space is also full, the OS has no way to free up space. On Linux, this triggers the OOM Killer, which terminates one or more memory-heavy processes to free up resources. On Windows, you'll get an "out of memory" error message, and the process may crash or be terminated.

内容的提问来源于stack exchange,提问作者Tung Nguyen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:07:59