Using boost :: serialization significantly increases binary size

I use fairly complex data structures (mainly using STL containers) in my application and serialize them using Boost (v1.34).

Whenever I compile with debugging symbols (gcc -g), the resulting executable becomes huge - about 25 MB. Removing all debug symbols reduces the size to ~ 3 MB.

I tried to nail the reason for the increase in size, and it seems that the reason for this is serialization methods. In particular, the object files for modules that cause serialization (code like "oarchive <myObject") are large, and commenting on part of the serialization significantly reduces the size.

Is it possible to prevent the generation of these characters or to selectively separate them?
Removing all characters is not an option, as I need debugging characters for my own code.

+5
source share
2 answers
  • Put your code with serialization calls in separate modules, compile them into large object files.
  • Use strip -strip-debug on them to remove only these big debugging symbols (which you will definitely need later to debug the failures inside the serialization library :)
  • Profit! Tie the bypass wrappers and remove the other modules together.
+4
source
strip -w -K '!*serialization*'

, . :

# 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*
+2

All Articles