chore(mem-tracker): fix mmap allocator
@@ -58,14 +58,14 @@ pub mod linux {
return Err(AllocError);
}
let addr = NonNull::new(addr as *mut ()).ok_or(AllocError)?;
- ThreadTracker::alloc_memory(layout.size() as i64, &addr);
+ ThreadTracker::alloc_memory(layout.size() as i64);
Ok(NonNull::<[u8]>::from_raw_parts(addr, layout.size()))
}
#[inline(always)]
unsafe fn mmap_dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
debug_assert!(layout.align() <= page_size());
- ThreadTracker::dealloc_memory(layout.size() as i64, &ptr);
+ ThreadTracker::dealloc_memory(layout.size() as i64);
let result = libc::munmap(ptr.cast().as_ptr(), layout.size());
assert_eq!(result, 0, "Failed to deallocate.");
}
@@ -80,7 +80,8 @@ pub mod linux {
debug_assert!(old_layout.align() <= page_size());
debug_assert!(old_layout.align() == new_layout.align());
- ThreadTracker::dealloc_memory(old_layout.size() as i64, &ptr);
+ ThreadTracker::dealloc_memory(old_layout.size() as i64);
+ ThreadTracker::alloc_memory(new_layout.size() as i64);
const REMAP_FLAGS: i32 = libc::MREMAP_MAYMOVE;
let addr = libc::mremap(
@@ -93,7 +94,6 @@ pub mod linux {
return Err(AllocError);
}
let addr = NonNull::new(addr as *mut ()).ok_or(AllocError)?;
- ThreadTracker::alloc_memory(new_layout.size() as i64, &addr);
if linux_kernel_version() >= (5, 14, 0) {
libc::madvise(addr.cast().as_ptr(), new_layout.size(), MADV_POPULATE_WRITE);
}
@@ -110,7 +110,8 @@ pub mod linux {
debug_assert!(old_layout.align() <= page_size());
debug_assert!(old_layout.align() == new_layout.align());
- ThreadTracker::dealloc_memory(old_layout.size() as i64, &ptr);
+ ThreadTracker::dealloc_memory(old_layout.size() as i64);
+ ThreadTracker::alloc_memory(new_layout.size() as i64);
const REMAP_FLAGS: i32 = libc::MREMAP_MAYMOVE;
let addr = libc::mremap(
@@ -124,8 +125,6 @@ pub mod linux {
}
let addr = NonNull::new(addr as *mut ()).ok_or(AllocError)?;
- ThreadTracker::alloc_memory(new_layout.size() as i64, &addr);
-
Ok(NonNull::<[u8]>::from_raw_parts(addr, new_layout.size()))
}
}
