Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the memory usage overhead for a 64-bit application?

From what I have found so far it's clear that programs compiled for a 64-bit architecture use twice as much RAM for pointers as their 32-bit alternatives - https://superuser.com/questions/56540/32-bit-vs-64-bit-systems.

Does that mean that code compiled for 64-bit uses on average two times more RAM than the 32-bit version?

I somehow doubt it, but I am wondering what the real overhead is. I suppose that small types, like short, byte and char are same sized in a 64-bit architecture? I am not really sure about byte though. Given that many applications work with large strings (like web browsers, etc.), that consist mostly of char arrays in most implementations, the overhead may not be so large.

So even if numeric types like int and long are larger on 64 bit, would it have a significant effect on usage of RAM or not?

like image 727
Petr Avatar asked Mar 19 '15 08:03

Petr


People also ask

How much memory can a 64-bit application use?

The theoretical memory limit that a 64-bit computer can address is about 16 exabytes (16 billion gigabytes), Windows XP x64 is currently limited to 128 GB of physical memory and 8 TB of virtual memory. In the future this limit will be increased, basically because hardware capabilities will improve.

How much memory is 64bit?

A 64-bit register can theoretically reference 18,446,744,073,709,551,616 bytes, or 17,179,869,184 GB (16 exabytes) of memory. This is several million times more than an average workstation would need to access.

Why does 64-bit need more RAM?

The reasons to go 64-bit include greater access to memory for 64-bit applications, access to more than 4GB of physical RAM (although often systems only see around 3GB because other devices use up the memory address space), and improved security capabilities.

What does a 64-bit operating system mean?

A 64-bit processor refers to a microprocessor that can process data and instructions in chunks of 64 bits. Microprocessors that can handle 64 bits perform a larger number of calculations per second compared to 32-bit processors.


1 Answers

It depends on the programming style (and on the language, but you are referring to C).

  • If you work a lot with pointers (or you have a lot of references in some languages), RAM consumption goes up.
  • If you use a lot of data with fixed size, such as double or int32_t, RAM consumption does not go up.
  • For types like int or long, it depends on the architecture; there may be differences between Linux and Windows. Here you see the alternatives you have. In short, Windows uses LLP64, meaning that long long and pointers are 64 bit, while Linux uses LP64, where longis 64 bit as well. Other architectures might make int or even short 64 bit as well, but these are quite uncommon.
  • float and double should remain the same in size in all cases.

So you see it strongly depends on the usage of the data types.

like image 92
glglgl Avatar answered Oct 19 '22 02:10

glglgl