Pool size is doubled on each ordered_malloc call

Open
#1,060 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Start by running the provided C++ sample and inspect the Boost pool implementation related to ordered_malloc(), ordered_free(), purge_memory(), and get_next_size(). Compare the behavior between Boost 1.70 and 1.88; done means repeated purge_memory() calls no longer cause the reported pool-size doubling.

Written by the indexing model from the issue text.

Description

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
Dominant language
HTML
Stars
8.6k
Forks
2k
Avg merge
9h 35m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/boost

All issues in boostorg/boost

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.