Boost Bimap在调试版本中占用过多内存 [英] Boost Bimap takes too much memory in debug build

查看:122
本文介绍了Boost Bimap在调试版本中占用过多内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用很多形式的容器

I am using quite a few containers of the form

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

我在很多cpp文件中包含的头文件中定义它们(这是在我尽可能限制头文件的显示之后).在调试版本中创建的.a文件运行到1 GB以上(由于设备上无空间"错误,导致编译中途停止,因此编译时间自然呈指数增长.

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.

使用的编译器是gcc 4.8.1.只是想知道是否有人使用boost :: bimap遇到了这个问题,以及他们为解决这个问题做了什么

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

推荐答案

我很可能每次您在不同文件中使用这样的bimap时,它都会专门导致巨大的代码重复.如果使用的是c++11,则应将它们声明为extern template,并仅将其专用于一个文件.请参见使用外部模板(C ++ 11)

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)

这篇关于Boost Bimap在调试版本中占用过多内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆