boost库中的fast_pool_allocator会导致内存泄露

paschen 版主 2015-10-04 06:26:02
VS2012下boost_1_55_0

如下方式申明一个变量:
std::vector<int, boost::fast_pool_allocator<int> > vec;


不对vec进行任何操作,程序结束后会显示:

Detected memory leaks!
Dumping objects ->
{735} normal block at 0x006E3C30, 264 bytes long.
Data: <8<n @<n > 38 3C 6E 00 00 00 00 00 40 3C 6E 00 CD CD CD CD
Object dump complete.

但如果不用boost提供的分配器,写成
std::vector<int> vec;
就不会内存泄露


这难道是boost库的问题还是?
...全文
199 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
iyomumx 2015-10-04
  • 打赏
  • 举报
回复
引用 4 楼 paschen 的回复:
[quote=引用 3 楼 iyomumx 的回复:] [quote=引用 2 楼 paschen 的回复:] [quote=引用 1 楼 iyomumx 的回复:] 文档里有说明啊
引用
The underlying singleton_pool used by the this allocator constructs a pool instance that is never freed. This means that memory allocated by the allocator can be still used after main() has completed, but may mean that some memory checking programs will complain about leaks.
我没具体研究,也就是要自己释放吗?要怎么写?[/quote] 好像是没法释放的[/quote] 你说的文档是什么?可以发下链接?[/quote] boost目录里的html文档,在线的应该是这个: http://www.boost.org/doc/libs/1_57_0/libs/pool/doc/html/boost/fast_pool_allocator.html
paschen 版主 2015-10-04
  • 打赏
  • 举报
回复
引用 3 楼 iyomumx 的回复:
[quote=引用 2 楼 paschen 的回复:] [quote=引用 1 楼 iyomumx 的回复:] 文档里有说明啊
引用
The underlying singleton_pool used by the this allocator constructs a pool instance that is never freed. This means that memory allocated by the allocator can be still used after main() has completed, but may mean that some memory checking programs will complain about leaks.
我没具体研究,也就是要自己释放吗?要怎么写?[/quote] 好像是没法释放的[/quote] 你说的文档是什么?可以发下链接?
iyomumx 2015-10-04
  • 打赏
  • 举报
回复
引用 2 楼 paschen 的回复:
[quote=引用 1 楼 iyomumx 的回复:] 文档里有说明啊
引用
The underlying singleton_pool used by the this allocator constructs a pool instance that is never freed. This means that memory allocated by the allocator can be still used after main() has completed, but may mean that some memory checking programs will complain about leaks.
我没具体研究,也就是要自己释放吗?要怎么写?[/quote] 好像是没法释放的
paschen 版主 2015-10-04
  • 打赏
  • 举报
回复
引用 1 楼 iyomumx 的回复:
文档里有说明啊
引用
The underlying singleton_pool used by the this allocator constructs a pool instance that is never freed. This means that memory allocated by the allocator can be still used after main() has completed, but may mean that some memory checking programs will complain about leaks.
我没具体研究,也就是要自己释放吗?要怎么写?
iyomumx 2015-10-04
  • 打赏
  • 举报
回复
文档里有说明啊
引用
The underlying singleton_pool used by the this allocator constructs a pool instance that is never freed. This means that memory allocated by the allocator can be still used after main() has completed, but may mean that some memory checking programs will complain about leaks.

64,701

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧