Visual C++ Express 2008:为什么它在发布可执行文件的末尾放置大量空字节?
最近我发现我的发布可执行文件(使用 msvc++express 2008 制作)变得非常大。 当我使用十六进制查看器检查可执行文件时,我发现只有前 300k 字节包含有用数据,其余字节仅为零 - 6 兆零字节。
调试生成的 exe 大小为 1MB,但发布版本为 6.5MB。
为什么MSVC++express要做那些无用的事情? 我该如何修复它?
Recently I have discovered that my release executable (made with msvc++ express 2008) becomes very large. As I examine the executable with a hex viewer I saw that only the first 300k bytes contains useful data the remaining bytes are only zeros - 6 megs of zero bytes.
The debug built exe has 1MB size, but the release is 6.5MB.
Why does MSVC++ express do that useless thing? How can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
发布版本比调试版本大 6 倍 - 可能有问题。
尝试创建一个新项目并复制源代码。 编译它并查看调试和发布可执行文件的结果。
Release 6 times larger than Debug - something is probably wrong.
Try to create a fresh project and just copy your source code. Compile it and see what you get for the Debug and Release executables.
也许您在发布中静态链接 .exe,但在调试中动态链接? 检查这是项目属性对话框。
另一种可能性是,在发布模式下,内联了许多函数,或者您正在使用大量模板。
您可以在“项目属性”对话框中告诉编译器优化大小。
Perhaps you are statically linking your .exe in release, but dynamically linking in debug? Check this is the dialog Project Properties.
Another possibility is that in release mode a lot of functions are inlined or you are using a lots of templates.
You can tell the compiler to optimize for size in the dialog Project Properties.
您是否在程序中的文件范围内定义了大型数组? 这可能是原因之一。 您可以使用 dumpbin 程序查看 exe 文件中每个部分占用了多少空间,这应该可以让您了解“原因”。
Did you define large arrays at file-scope in your program? That might be one reason. You can use the dumpbin program to see how much space each section in the exe file takes, that should give you a clue to the "why".