Struct AllocationInfo

Source
pub struct AllocationInfo {
Show 17 fields pub ptr: usize, pub size: usize, pub timestamp_alloc: u128, pub timestamp_dealloc: Option<u128>, pub var_name: Option<String>, pub type_name: Option<String>, pub thread_id: String, pub peak_size: Option<usize>, pub growth_events: usize, pub scope_name: Option<String>, pub ownership_pattern: Option<OwnershipPattern>, pub risk_level: Option<RiskLevel>, pub efficiency_score: Option<f64>, pub borrow_count: usize, pub mut_borrow_count: usize, pub transfer_count: usize, pub metadata_tags: Vec<String>,
}
Expand description

Enhanced information about a memory allocation with lifecycle tracking

Fields§

§ptr: usize

Memory address of the allocation

§size: usize

Size of the allocation in bytes

§timestamp_alloc: u128

Timestamp when the allocation occurred (milliseconds since UNIX_EPOCH)

§timestamp_dealloc: Option<u128>

Timestamp when the deallocation occurred (if applicable)

§var_name: Option<String>

Optional name of the variable associated with this allocation

§type_name: Option<String>

Optional type name of the variable associated with this allocation

§thread_id: String

Thread ID where the allocation occurred

§peak_size: Option<usize>

Peak memory size reached during lifetime (for growable types)

§growth_events: usize

Number of memory growth events (reallocations)

§scope_name: Option<String>

Scope identifier where this allocation occurred

§ownership_pattern: Option<OwnershipPattern>

Ownership pattern for this allocation

§risk_level: Option<RiskLevel>

Risk classification for this allocation

§efficiency_score: Option<f64>

Memory efficiency score (useful_bytes / allocated_bytes)

§borrow_count: usize

Borrowing events count (how many times this was borrowed)

§mut_borrow_count: usize

Mutable borrowing events count

§transfer_count: usize

Ownership transfer events

§metadata_tags: Vec<String>

Custom metadata tags

Implementations§

Source§

impl AllocationInfo

Source

pub fn new(ptr: usize, size: usize) -> Self

Create a new allocation info with enhanced lifecycle tracking

Source

pub fn mark_deallocated(&mut self)

Mark this allocation as deallocated

Source

pub fn is_active(&self) -> bool

Check if this allocation is still active

Source

pub fn lifetime_ms(&self) -> Option<u128>

Get the lifetime of this allocation in milliseconds

Source

pub fn record_growth(&mut self, new_size: usize)

Record a memory growth event (reallocation)

Source

pub fn record_borrow(&mut self, is_mutable: bool)

Record a borrowing event

Source

pub fn record_transfer(&mut self)

Record an ownership transfer

Source

pub fn add_metadata_tag(&mut self, tag: String)

Add a metadata tag

Source

pub fn memory_growth_factor(&self) -> f64

Calculate memory growth factor

Source

pub fn classify_risk(&mut self)

Classify the risk level of this allocation

Source

pub fn determine_ownership_pattern(&mut self)

Determine ownership pattern based on type

Trait Implementations§

Source§

impl Clone for AllocationInfo

Source§

fn clone(&self) -> AllocationInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AllocationInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AllocationInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AllocationInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,