There seems to be a bug in the implementation of SkipMap leading to memory leaks. I found this while investigating #11 which refers to a different area though.
Instrumenting the Drop implementation:
impl Drop for Node {
fn drop(&mut self) {
// large object should drop
if let Some(mut next) = self.next.take() {
println!("destroyed {:?}", next.key);
while let Some(child) = next.next.take() {
next = child;
println!("destroyed {:?}", next.key);
}
}
println!("destroyed {:?}", self.key);
unsafe {
for skip in self.skips.iter_mut() {
if let Some(mut next) = skip.take() {
while let Some(child) = (*next).next.take() {
next = Box::into_raw(child);
}
}
}
}
}
}
gives
running 1 test
destroyed [97, 98, 97]
destroyed [97, 98, 97]
destroyed [97, 98, 98]
destroyed [97, 98, 98]
destroyed []
test skipmap::tests::test_skipmap_iterator_init ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 142 filtered out; finished in 0.00s
There seems to be a bug in the implementation of
SkipMap
leading to memory leaks. I found this while investigating #11 which refers to a different area though.Instrumenting the
Drop
implementation:gives
for a skipmap constructed as