Fix try_shrink not freeing back to pool#20382
Conversation
|
@andygrove FYI |
|
@cetra3 @mbutrovich @comphead : Any chance we could get this in a patch to branch-51? I can run the backports but would be interested to have this fix there. (I can backport to branch-52 as well) |
We should prob wait for DF 53 release which should be pretty soon |
I would be interested in a backport to DF52. I will bring it here: #20287. If you open the backport PR for 52, could you add it to that tracking issue? I am not sure if we are planning another 51 patch release. |
|
@mbutrovich @comphead : Sorry, my bad here. This PR only fixes a bug introduced by #19759 so branch-51 and branch-52 (which use usize instead of AtomicUsize) do not have the bug. pub fn try_shrink(&mut self, capacity: usize) -> Result<usize> {
if let Some(new_size) = self.size.checked_sub(capacity) {
self.registration.pool.shrink(self, capacity);
self.size = new_size;
Ok(new_size)
} else {
internal_err!(
"Cannot free the capacity {capacity} out of allocated size {}",
self.size
)
}
}Which already calls pool.shrink() correctly. I was debugging another issue I am running into and I thought this would be the fix for branch-51/branch-52 as well but that is not the case :( |
Which issue does this PR close?
No issue raised
Rationale for this change
try_shrinknever released any memory from the pool, and so would cause a "memory leak"What changes are included in this PR?
A few changes to
MemoryReservationAre these changes tested?
Yes & new test has been added
Are there any user-facing changes?
Nope