Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of 64-bit dll 50% larger than 32-bit

I have a VC++ project (2005) that generates both 32-bit and 64-bit dlls. The 32-bit dll is 1044 KB whereas the 64-bit version is 1620 KB. I'm curious why the size is so large. Is it just because of the larger address size, or is there a compiler option that I'm missing?

like image 874
Amit G Avatar asked Oct 19 '09 16:10

Amit G


People also ask

What is the difference between 32-bit and 64-bit DLL?

If the first DLL in the path is 32 bit and your app is 32 bit, then the DLL load will work. If the app is 64 bit, it will fail to load the DLL and the process will abort. If you want two DLLs to coexist on the system path, you need to give them unique file names.

Is 64bit bigger than 32?

64-bit memory addresses are twice as long as 32-bit memory addresses, so 64-bit pointers are also twice as long. 64-bit programs that make heavy use of pointers will be noticeably larger than their 32-bit counterparts.

Can a 64-bit DLL call a 32-bit DLL?

On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL).

Is 32bit smaller than 64-bit?

The biggest difference between 32-bit and 64-bit OSes is that the 32-bit version can only address a bit less than 4GB of memory, in total, for the entire system, and this includes the memory in your video card. For Windows it's usually about 3.5GB total.


1 Answers

Maybe your code contains a lot of pointers.

The Free Lunch Is Over

....

(Aside: Here’s an anecdote to demonstrate “space is speed” that recently hit my compiler team. The compiler uses the same source base for the 32-bit and 64-bit compilers; the code is just compiled as either a 32-bit process or a 64-bit one. The 64-bit compiler gained a great deal of baseline performance by running on a 64-bit CPU, principally because the 64-bit CPU had many more registers to work with and had other code performance features. All well and good. But what about data? Going to 64 bits didn’t change the size of most of the data in memory, except that of course pointers in particular were now twice the size they were before. As it happens, our compiler uses pointers much more heavily in its internal data structures than most other kinds of applications ever would. Because pointers were now 8 bytes instead of 4 bytes, a pure data size increase, we saw a significant increase in the 64-bit compiler’s working set. That bigger working set caused a performance penalty that almost exactly offset the code execution performance increase we’d gained from going to the faster processor with more registers. As of this writing, the 64-bit compiler runs at the same speed as the 32-bit compiler, even though the source base is the same for both and the 64-bit processor offers better raw processing throughput. Space is speed.)

like image 105
Khaled Alshaya Avatar answered Sep 28 '22 03:09

Khaled Alshaya