[英]Using boost::serialization greatly increases binary size
I use rather complex data structures (mostly using STL containers) in my app, and serialize them using Boost (v1.34). 我在应用程序中使用了相当复杂的数据结构(主要使用STL容器),并使用Boost(v1.34)对它们进行序列化。
Whenever I compile with debug symbols (gcc -g), the resulting executable gets huge - around 25 MB. 每当我使用调试符号(gcc -g)进行编译时,生成的可执行文件都会变得很大-大约25 MB。 Stripping all the debug symbols reduces the size to ~3 MB.
剥离所有调试符号会将大小减小到〜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.
特别是,用于调用序列化的模块的目标文件(诸如“ oarchive << myObject”之类的代码)很大,注释掉序列化部分会大大减小大小。
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*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.