💻 Memory Addressing — The Root of It All
1️⃣ What does “32-bit” mean?
A 32-bit CPU (or app) means that pointers (memory addresses) are 32 bits long.
That’s a binary number with 32 ones and zeros, meaning:
2^32 = 4,294,967,296 addresses
= 4GB addressable memory (in theory)
2️⃣ What does “64-bit” mean?
A 64-bit CPU (or app) uses 64-bit pointers, meaning:
2^64 = 18,446,744,073,709,551,616 addresses
= 16 exabytes of addressable memory
📏 Why 32-bit Apps Get Only 2GB or 3GB (Not 4GB)?
This is the real-world catch — even though 32-bit has 4GB of addressable space, the operating system splits that space into:
Section | Who Uses It |
---|---|
User Space (your app) | Typically 2GB or 3GB |
Kernel Space (OS itself) | 1GB or 2GB |
On Windows 32-bit:
- Default split: 2GB for user, 2GB for kernel.
- Can be tuned to 3GB user, 1GB kernel using
/3GB
boot flag.
On Linux 32-bit:
- Similar — usually 3GB user, 1GB kernel.
Why reserve space for the kernel?
The kernel (OS) needs direct memory access for drivers, devices, file systems, etc. This is why the app doesn’t get the full 4GB.
🧮 Calculation Recap
Arch | Pointer Size | Total Addressable Memory | App Can Use (User Space) |
---|---|---|---|
32-bit | 4 bytes | 4GB | 2-3GB (OS eats some) |
64-bit | 8 bytes | 16 exabytes | Practically all of it (depends on OS and hardware limits) |
⚠️ Important Note — Physical RAM vs Address Space
- These limits are address space, not physical RAM.
- If you have 32GB of physical RAM but a 32-bit process, it still can’t use more than 2-3GB — it just has no more addresses available.
- In 64-bit processes, the address space is so huge you effectively hit physical RAM limits before address space limits.
🚀 Example Calculation — 32-bit Addressing
- 32-bit address = 4 bytes
- Max addresses = 2^32 = 4,294,967,296 = 4GB address space
- OS reserves 1-2GB for kernel
- App gets 2GB or 3GB user space
🚀 Example Calculation — 64-bit Addressing
- 64-bit address = 8 bytes
- Max addresses = 2^64 = 16 exabytes
- OS might limit user processes to, say, 128TB per process (depends on OS)
🔥 Summary Table
Bitness | Max Theoretical Address Space | Real User Space (in practice) |
---|---|---|
32-bit | 4GB | 2GB (Windows default) or 3GB (with tuning) |
64-bit | 16 exabytes | Essentially whatever the OS/hardware allows (hundreds of TBs usually) |
🔬 In the JVM Context
- 32-bit JVM → Max heap ~2GB (some OSes allow ~3GB if you tweak boot options)
- 64-bit JVM → Heap can grow to hundreds of GB or more (depending on OS & hardware)
💡 Easy Rule of Thumb
Bitness | Memory Limit |
---|---|
32-bit | 2-3GB per process |
64-bit | Your hardware is the limit |