Boost Bimap takes too much memory in debug build

橙三吉。 提交于 2019-12-11 06:51:01

问题


I am using quite a few containers of the form

boost::bimap<boost::bimaps::multiset_of<std::string>, boost::bimaps::set_of<AnEnum> >

I am defining them in a header file that is included in quite a few cpp files (This is after I limited the exposure of the header file as much as possible). The .a files being created in the debug build runs to above 1 GB (resulting in compilation stopping midway due to 'no space on device' error and naturally the compile time has increased exponentially.

The compiler being used is gcc 4.8.1. Just wanted to know if anyone has encountered this problem with boost::bimap and what they did to resolve this issue


回答1:


I is very likely that each time you use such a bimap in a different file, it is specialized leading to huge code duplication. If you are using c++11 then you should declare them as extern template, And specialize it in only one file. See using extern template (C++11)



来源:https://stackoverflow.com/questions/22166315/boost-bimap-takes-too-much-memory-in-debug-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!