gpt4 book ai didi

c++ - 64 位 dll 的大小比 32 位大 50%

转载 作者:可可西里 更新时间:2023-11-01 15:46:05 24 4
gpt4 key购买 nike

我有一个生成 32 位和 64 位 dll 的 VC++ 项目 (2005)。 32 位 dll 为 1044 KB,而 64 位版本为 1620 KB。我很好奇为什么尺寸这么大。仅仅是因为地址大小较大,还是我缺少编译器选项?

最佳答案

也许您的代码包含很多指针。

The Free Lunch Is Over

....

(Aside:Here’s an anecdote to demonstrate“space is speed” that recently hit mycompiler team. The compiler uses thesame source base for the 32-bit and64-bit compilers; the code is justcompiled as either a 32-bit process ora 64-bit one. The 64-bit compilergained a great deal of baselineperformance by running on a 64-bitCPU, principally because the 64-bitCPU had many more registers to workwith and had other code performancefeatures. All well and good. But whatabout data? Going to 64 bits didn’tchange the size of most of the data inmemory, except that of course pointersin particular were now twice the sizethey were before. As it happens, ourcompiler uses pointers much moreheavily in its internal datastructures than most other kinds ofapplications ever would. Becausepointers were now 8 bytes instead of 4bytes, a pure data size increase, wesaw a significant increase in the64-bit compiler’s working set. Thatbigger working set caused aperformance penalty that almostexactly offset the code executionperformance increase we’d gained fromgoing to the faster processor withmore registers. As of this writing,the 64-bit compiler runs at the samespeed as the 32-bit compiler, eventhough the source base is the same forboth and the 64-bit processor offersbetter raw processing throughput.Space is speed.)

关于c++ - 64 位 dll 的大小比 32 位大 50%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1589742/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com