Opened 13 years ago
Closed 12 years ago
#3349 closed Bugs (fixed)
ordered_malloc not always keeps the free list ordered.
Reported by: | Owned by: | Chris Newbold | |
---|---|---|---|
Milestone: | Boost 1.40.0 | Component: | pool |
Version: | Boost 1.39.0 | Severity: | Problem |
Keywords: | pool, ordered_malloc, add_block | Cc: | boostpool@… |
Description
Hello,
In function
template <typename UserAllocator> void * pool<UserAllocator>::ordered_malloc(const size_type n)
in pool.hpp, I saw the code below along with the comments:
// Split up block so we can use what wasn't requested // (we can use "add_block" here because we know that // the free list is empty, so we don't have to use // the slower ordered version) if (next_size > num_chunks) store().add_block(node.begin() + num_chunks * partition_size, node.element_size() - num_chunks * partition_size, partition_size);
However, here I don't see why the free list must be empty. In my case, the free list is not empty. The new free chunks are added to the beginning of the free list and all existing ones are appended to the new ones, making the list out of order.
I guess using ordered_add_block could easily solve this problem.
Change History (3)
comment:1 by , 13 years ago
comment:2 by , 12 years ago
Cc: | added |
---|
comment:3 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed as part of [67792]
Note:
See TracTickets
for help on using tickets.
BTW, I wrote a simple program to show this. The variable "any_memory_released" is false after the release because the free list is out of order. If we change the "add_block" to "add_ordered_block" then "any_memory_released" is true.