Open
Description
I tried this code:
fn main() {
let allocator = AllocWrapper(Arc::new(std::alloc::System));
println!("count = {}", Arc::strong_count(&allocator.0));
let mut btree_map: BTreeMap<i32, i32, _> = BTreeMap::new_in(allocator.clone());
println!("count = {}", Arc::strong_count(&allocator.0));
btree_map.insert(1, 1);
println!("count = {}", Arc::strong_count(&allocator.0));
drop(btree_map);
println!("count = {}", Arc::strong_count(&allocator.0)); // expect 1 got 2!
}
I expected to see this happen:
The reference count of the Arc
should reduce to 1, so that it can be released correctly.
Instead, this happened:
The reference count of the Arc
remains 2, so it will never be released.
Meta
Build using the Nightly version: 1.68.0-nightly
(2022-12-26 88c58e3c2c097ebffac4)
with
#![feature(btreemap_alloc)]
#![feature(allocator_api)]