I use rather complex data structures (mostly using STL containers) in my app, and serialize them using Boost (v1.34).
Whenever I compile with debug symbols (gcc -g), the resulting executable gets huge - around 25 MB. Stripping all the debug symbols reduces the size to ~3 MB.
I tried to nail down the cause of the size increase, and it seems that serialization methods are the cause. Particularly, object files for modules that call serialization (code like "oarchive << myObject") are large, and commenting out the serialization part reduces the size significantly.
Is it possible to prevent generation of these symbols, or to strip them selectively?
Stripping all the symbols is not an option, since I need debug symbols for my own code.
strip -w -K '!*serialization*'
Easy, no need for compile time gymnastics. Here's the improvement this made to my binary:
# ls -lh EnrollGUI
-rwxr-xr-x. 1 root root 17M Aug 8 2012 EnrollGUI*
# strip -w -K '!*serialization*' EnrollGUI
# ls -lh EnrollGUI
-rwxr-xr-x. 1 root root 1.1M Aug 8 2012 EnrollGUI*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With