Pool size is doubled on each ordered_malloc call

未关闭
#1,060 1 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
backend

调研方向

首先运行提供的 C++ 示例,并检查与 ordered_malloc()、ordered_free()、purge_memory() 和 get_next_size() 相关的 Boost pool 实现。比较 Boost 1.70 和 1.88 之间的行为;当重复调用 purge_memory() 不再导致报告的 pool 大小翻倍时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Encountered a similar issue with: https://github.com/boostorg/pool/issues/54 when I upgraded from boost 1.70 to 1.88. Repeated use of purge_memory() results in pool size extension with two times the previous size when ordered_malloc is called.

Sample Code:

int main()
{
    boost::pool<> bufferMemPool(sizeof(WCHAR), 32768);
    for (int i = 0; i < 10; i++)
    {
        LPWSTR buffer = static_cast<LPWSTR>(bufferMemPool.ordered_malloc());
        if (buffer) {
            std::wcout << "get_next_size(): " << bufferMemPool.get_next_size() << std::endl;
            bufferMemPool.ordered_free(buffer);
        }
        else {
            std::wcerr << L"Memory allocation failed." << std::endl;
        }

        bufferMemPool.purge_memory();
    }

    return 0;
}

Output:

get_next_size(): 65536
get_next_size(): 131072
get_next_size(): 262144
get_next_size(): 524288
get_next_size(): 1048576
get_next_size(): 2097152
get_next_size(): 4194304
get_next_size(): 8388608
get_next_size(): 16777216
get_next_size(): 33554432
主要语言
HTML
星标
8.6k
派生
2k
平均合并
9 小时 35 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

boostorg/boost 的其他 Issue

查看 boostorg/boost 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。