Remix.run Logo
calebh 6 days ago

Perhaps the reason modern programs use so much memory vs what I remember from the Windows XP era is precisely because we went to 64 bits. Imagine how many pointers are used in the average program. When we switched over to 64 bits, the memory used by all those pointers instantly doubled. It's clear that 32 bits wasn't enough, but maybe some intermediate number between 32 and 64 would have added sufficient capacity without wasting a ton of extra space.

zozbot234 6 days ago | parent | next [-]

> Imagine how many pointers are used in the average program. When we switched over to 64 bits, the memory used by all those pointers instantly doubled.

This is a very real issue (not just on the Windows platform, either) but well-coded software can recover much of that space by using arena allocation and storing indexes instead of general pointers. It would also be nice if we could easily restrict the system allocator to staying within some arbitrary fraction of the program's virtual address space - then we could simply go back to 4-byte general pointers (provided that all library code was updated in due course to support this too) and not even need to mess with arenas.

(We need this anyway to support programs that assume a 48-bit virtual address space on newer systems with 56-bit virtual addresses. Might as well deal with the 32-bit case too.)

iainmerrick 5 days ago | parent | prev | next [-]

I agree that's wasteful, but if software were only 2x bigger, we'd be in really good shape now. Unfortunately there are still another one or two more orders of magnitude to account for somehow.

Tor3 6 days ago | parent | prev | next [-]

SGI used three ABIs for their 64-bit computers.. O32, N32, N64. N32 was 64-bit except for pointers which were still 32 bits for exactly that reason - to avoid doubling the memory needed for storing pointers.

IshKebab 6 days ago | parent [-]

https://en.wikipedia.org/wiki/X32_ABI

piperswe 5 days ago | parent | prev | next [-]

The x32 ABI has 32-bit integers and pointers, while still running in long mode with full access to modern CPU features and instructions

frutiger 6 days ago | parent | prev [-]

Because of aligned reads any pointer size between 32-bit and 64-bit would end up using 64-bits anyway.

IshKebab 6 days ago | parent [-]

With 8-bit bytes, yes.