pub struct BudgetManager { /* private fields */ }Expand description
Manages memory budgets and limits with per-tag tracking.
Implementations§
Source§impl BudgetManager
impl BudgetManager
Sourcepub fn set_event_callback<F>(&self, callback: F)
pub fn set_event_callback<F>(&self, callback: F)
Set a callback for budget events.
Sourcepub fn register_tag(
&self,
tag: &AllocationTag,
soft_limit: usize,
hard_limit: usize,
)
pub fn register_tag( &self, tag: &AllocationTag, soft_limit: usize, hard_limit: usize, )
Register a budget for a specific tag.
Sourcepub fn register_tag_budget(
&self,
name: &'static str,
soft_limit: usize,
hard_limit: usize,
)
pub fn register_tag_budget( &self, name: &'static str, soft_limit: usize, hard_limit: usize, )
Register a budget by tag name.
Sourcepub fn check_allocation(&self, size: usize, new_total: usize) -> BudgetStatus
pub fn check_allocation(&self, size: usize, new_total: usize) -> BudgetStatus
Check if an allocation is within budget (global check).
Sourcepub fn check_tagged_allocation(
&self,
tag: &AllocationTag,
size: usize,
) -> BudgetStatus
pub fn check_tagged_allocation( &self, tag: &AllocationTag, size: usize, ) -> BudgetStatus
Check and record a tagged allocation.
Sourcepub fn record_tagged_deallocation(&self, tag: &AllocationTag, size: usize)
pub fn record_tagged_deallocation(&self, tag: &AllocationTag, size: usize)
Record a tagged deallocation.
Sourcepub fn current_usage(&self) -> usize
pub fn current_usage(&self) -> usize
Get current global usage.
Sourcepub fn global_limit(&self) -> usize
pub fn global_limit(&self) -> usize
Get global limit.
Sourcepub fn get_all_tag_budgets(&self) -> Vec<TagBudget>
pub fn get_all_tag_budgets(&self) -> Vec<TagBudget>
Get all tag budgets for reporting.
Sourcepub fn get_tag_budget(&self, tag: &AllocationTag) -> Option<TagBudget>
pub fn get_tag_budget(&self, tag: &AllocationTag) -> Option<TagBudget>
Get a specific tag’s budget.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset all tag statistics (but keep limits).
Auto Trait Implementations§
impl !Freeze for BudgetManager
impl RefUnwindSafe for BudgetManager
impl Send for BudgetManager
impl Sync for BudgetManager
impl Unpin for BudgetManager
impl UnwindSafe for BudgetManager
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