Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does generating pdb files increase the size of my native C++ exe?

Just by turning on Configuration Properties > Linker > Debugging > Generate Debug Info the size of my exe has increased from 2.11MB to 2.34MB

  1. What is that extra ~230KB being used for? I thought the exe should be roughly the same size (give or take an extra path to the pdb file) but not that much. Would there be any performance hit from this "bloat"?

  2. I've also seen Configuration Properties > C/C++ > General > Debug Information Format set to disabled in release mode while the pdb files are set to generate, is there any reason why this would be? From what I can tell the exe is the same size - it's just the PDB that gets bigger when you enable Program Database, I can't see a problem with this but I want to make sure there isn't some piece that I'm missing considering Program Database is the default for new projects in the release configuration.

like image 445
TownCube Avatar asked Jul 11 '11 13:07

TownCube


People also ask

How do I reduce PDB file size?

Compress the PDB using /PDBCompress. For clean link scenarios /PDBCOMPRESS instructs the linker to open the target PDB file in a mode that will lead to the operating system compressing the file content automatically as debug records are being written into the PDB file. This will result in a smaller PDB.

Do PDB files affect performance?

The executive summary answer: no, generating PDB files will have no impact on performance whatsoever.

Should you deploy PDB files?

PDB files contain debug symbols that allow you to debug your binary even in release mode. You don't have to (and probably shouldn't deploy them), as they might be used to reverse engineer your application. Do keep them archived somewhere, though, because they come in very handy when you want to debug a crash dump.

What does PDB file do?

A program database file (extension . pdb) is a binary file that contains type and symbolic debugging information gathered over the course of compiling and linking the project. A PDB file is created when you compile a C/C++ program with /ZI or /Zi or a Visual Basic, Visual C#, or JScript program with the /debug option.


1 Answers

The increase of size of the executable is probably due to the compiler including code that would have otherwise be optimized away. Try linking with /OPT:REF, and see if that drops the size back to around what it was.

As for the performance hit, it should not be significant. The bloat might cause caching of code to be less efficient, but on most cases that would be neglectable.

like image 91
eran Avatar answered Oct 30 '22 15:10

eran