pub struct MemoryLayoutTracker { /* private fields */ }Expand description
Memory layout tracking for defragmentation
Implementations§
Source§impl MemoryLayoutTracker
impl MemoryLayoutTracker
pub fn new() -> Self
Sourcepub fn calculate_fragmentation(&mut self) -> f64
pub fn calculate_fragmentation(&mut self) -> f64
Calculate current fragmentation index
Sourcepub fn add_free_region(&mut self, address: usize, size: usize)
pub fn add_free_region(&mut self, address: usize, size: usize)
Add a free region
Sourcepub fn add_allocated_block(
&mut self,
address: usize,
size: usize,
is_movable: bool,
)
pub fn add_allocated_block( &mut self, address: usize, size: usize, is_movable: bool, )
Add an allocated block
Sourcepub fn remove_free_region(&mut self, address: usize) -> Option<FreeRegion>
pub fn remove_free_region(&mut self, address: usize) -> Option<FreeRegion>
Remove a free region
Sourcepub fn remove_allocated_block(
&mut self,
address: usize,
) -> Option<AllocatedBlock>
pub fn remove_allocated_block( &mut self, address: usize, ) -> Option<AllocatedBlock>
Remove an allocated block
Sourcepub fn get_total_free_space(&self) -> usize
pub fn get_total_free_space(&self) -> usize
Get total free space
Sourcepub fn get_largest_free_block(&self) -> usize
pub fn get_largest_free_block(&self) -> usize
Get largest free block
Sourcepub fn get_movable_blocks(&self) -> Vec<&AllocatedBlock>
pub fn get_movable_blocks(&self) -> Vec<&AllocatedBlock>
Get movable blocks for compaction
Sourcepub fn coalesce_free_regions(&mut self) -> usize
pub fn coalesce_free_regions(&mut self) -> usize
Coalesce adjacent free regions
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryLayoutTracker
impl RefUnwindSafe for MemoryLayoutTracker
impl Send for MemoryLayoutTracker
impl Sync for MemoryLayoutTracker
impl Unpin for MemoryLayoutTracker
impl UnsafeUnpin for MemoryLayoutTracker
impl UnwindSafe for MemoryLayoutTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more