[libcxx-commits] [libcxx] [libc++] Fix "leak" of PMR resource in benchmark (PR #216114)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 14 00:24:26 PDT 2026
================
@@ -135,30 +135,35 @@ void associative_container_benchmarks(std::string container) {
using PMRContainer = adapt_operations<Container>::template rebind_alloc<
std::pmr::polymorphic_allocator<typename Container::value_type>>;
+ struct alignas(PMRContainer) PMRScratchSpace {
+ char storage[sizeof(PMRContainer)];
+ };
+
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
std::pmr::monotonic_buffer_resource rs(size * 64 * BatchSize); // 64 bytes should be enough per node
std::vector<PMRContainer> srcs;
srcs.reserve(BatchSize);
- for (size_t i = 0; i != BatchSize; ++i)
+ for (std::size_t i = 0; i != BatchSize; ++i)
srcs.emplace_back(&rs).insert(in.begin(), in.end());
- alignas(PMRContainer) char c[BatchSize * sizeof(PMRContainer)];
+ PMRScratchSpace c[BatchSize];
----------------
philnik777 wrote:
Can't we just have a union with an array inside it instead?
https://github.com/llvm/llvm-project/pull/216114
More information about the libcxx-commits
mailing list