DSA Factory
Free Memory management lessonsMemory management · Stage 1 · Paging · Step 2

How big is a page table?

Calculate the memory a page table takes, and see how page size trades table size against waste. About 12 minutes.

Quick check

A 32-bit address space with 4 KB pages and 4-byte entries needs a page table of:

  1. A4 MB
  2. B4 KB
  3. C4 GB
Show the answer

4 MB. 2^20 entries × 4 bytes = 4 MB.

Your problem

Page table size

A process has an address space of 2 to the power addressBits bytes, divided into pages of pageSizeBytes bytes (a power of two), and each page table entry takes entryBytes bytes. Return the size of a single-level page table in bytes.

Example
addressBits = 32, pageSizeBytes = 4096, entryBytes = 4 → 4194304

10 ≤ addressBits ≤ 40 · pageSizeBytes a power of two, at most 2^addressBits · 1 ≤ entryBytes ≤ 16

Solve it in your browserFree account, no card. Python, C++, Java or JavaScript, with hints if you get stuck, and your progress is saved.
Sign up free to solve