Visual C++ express 2008: Why does it places megs of null bytes at the end of the release executable?

StackOverflow https://stackoverflow.com/questions/477885

Question

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?

Was it helpful?

Solution

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".

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top