Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REGRESSION] Pool size is extended on each allocation #54

Open
orgads opened this issue Jun 22, 2023 · 1 comment · May be fixed by #55
Open

[REGRESSION] Pool size is extended on each allocation #54

orgads opened this issue Jun 22, 2023 · 1 comment · May be fixed by #55

Comments

@orgads
Copy link
Contributor

orgads commented Jun 22, 2023

Reported in Boost mailing list: https://lists.boost.org/Archives/boost/2023/06/254750.php

951ca57 changed malloc_need_resize() to use set_next_size(), which
sets start_size in addition to setting next_size. this causes repeated use
of purge_memory() to allocate 2x size after every use. as illustration:

#include <boost/pool/pool.hpp>
int main()
{
  boost::pool pool(8);
  for(int i = 0; i < 10; i++) {
    printf("%d %ld\n", i, pool.get_next_size());
    pool.purge_memory();
    void *ptr = pool.malloc();
    (void)ptr;
  }
}

before the commit the output is:

0 32
1 64
2 64
3 64
4 64
5 64
6 64
7 64
8 64
9 64

after the commit, the output is:

0 32
1 64
2 128
3 256
4 512
5 1024
6 2048
7 4096
8 8192
9 16384
orgads added a commit to orgads/pool that referenced this issue Jun 22, 2023
@orgads orgads linked a pull request Jun 22, 2023 that will close this issue
@joelhock
Copy link

thank you for the quick fix!!

orgads added a commit to orgads/pool that referenced this issue Jun 23, 2023
orgads added a commit to orgads/pool that referenced this issue Jun 23, 2023
orgads added a commit to orgads/pool that referenced this issue Jun 23, 2023
orgads added a commit to orgads/pool that referenced this issue Jun 24, 2023
orgads added a commit to orgads/pool that referenced this issue Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants