Skip to main content

MemoryEvent

Struct MemoryEvent 

Source
pub struct MemoryEvent {
Show 21 fields pub timestamp: u64, pub event_type: MemoryEventType, pub ptr: usize, pub size: usize, pub old_size: Option<usize>, pub new_ptr: Option<usize>, pub binding_serial: Option<u64>, pub degraded_release: bool, pub charge_outcome: Option<ChargeOutcome>, pub thread_id: u64, pub var_name: Option<String>, pub type_name: Option<String>, pub call_stack_hash: Option<u64>, pub thread_name: Option<String>, pub source_file: Option<String>, pub source_line: Option<u32>, pub module_path: Option<String>, pub clone_source_ptr: Option<usize>, pub clone_target_ptr: Option<usize>, pub stack_ptr: Option<usize>, pub task_id: Option<u64>,
}
Expand description

Unified memory event type

This structure captures all essential information about memory operations across all tracking backends (core, lockfree, async, unified).

Fields§

§timestamp: u64

Event timestamp (nanoseconds since epoch)

§event_type: MemoryEventType

Event type

§ptr: usize

Memory pointer address

§size: usize

Allocation size in bytes

§old_size: Option<usize>

Previous allocation size (for Reallocate events)

§new_ptr: Option<usize>

New address (for Reallocate events that moved the block).

None means the block stayed at ptr; Some(new_ptr) means it migrated, so the old address binding must be closed and a new one opened.

§binding_serial: Option<u64>

Capture-local binding identity, preserved across reallocation. Older event streams omit it and use address/size matching during replay.

§degraded_release: bool

Set when a release could only be matched by address (the address held several live bindings), so the closed binding was chosen by policy rather than identified.

Carried by the event instead of only a counter: replay and every export can then say that this release is a lower bound of the evidence, not an exact fact.

§charge_outcome: Option<ChargeOutcome>

Registry charge result captured before publishing an allocation. Missing on legacy streams and non-allocation events; replay must not replace it with live registry state.

§thread_id: u64

Thread identifier

§var_name: Option<String>

Optional variable name

§type_name: Option<String>

Optional type name

§call_stack_hash: Option<u64>

Optional call stack hash

§thread_name: Option<String>

Optional thread name

§source_file: Option<String>

Optional source file path

§source_line: Option<u32>

Optional source line number

§module_path: Option<String>

Optional module path

§clone_source_ptr: Option<usize>

Clone source pointer (for Clone events)

§clone_target_ptr: Option<usize>

Clone target pointer (for Clone events)

§stack_ptr: Option<usize>

Stack pointer (for StackOwner types like Arc/Rc)

§task_id: Option<u64>

Task ID (for task-aware memory tracking)

Implementations§

Source§

impl MemoryEvent

Source

pub fn allocate(ptr: usize, size: usize, thread_id: u64) -> Self

Create a new allocation event.

Constructing an event has no accounting side effect: task memory is recorded once at the capture site (see Tracker::track_inner), otherwise building an event — or replaying a recorded one — would double count.

Source

pub fn reallocate_moved( ptr: usize, new_ptr: usize, old_size: usize, new_size: usize, thread_id: u64, ) -> Self

Create a migrating reallocation event.

reallocate() describes a block that stayed at ptr; this variant records that the allocator returned a different address, so reconstruction can close the old binding and open one at new_ptr.

Source

pub fn deallocate(ptr: usize, size: usize, thread_id: u64) -> Self

Create a new deallocation event

Source

pub fn reallocate( ptr: usize, old_size: usize, new_size: usize, thread_id: u64, ) -> Self

Create a new reallocation event

Source

pub fn metadata( var_name: String, type_name: String, thread_id: u64, size: usize, ) -> Self

Create a new metadata event for Container/Value types (no heap allocation)

Source

pub fn clone_event( source_ptr: usize, target_ptr: usize, size: usize, thread_id: u64, var_name: Option<String>, type_name: Option<String>, ) -> Self

Create a new clone event

Source

pub fn borrow(ptr: usize, size: usize, thread_id: u64, is_mutable: bool) -> Self

Create a new borrow event

Source

pub fn now() -> u64

Get current timestamp in nanoseconds Returns 0 if system time is before Unix epoch (should not happen in practice)

Source

pub fn with_var_name(self, name: String) -> Self

Set variable name

Source

pub fn with_type_name(self, name: String) -> Self

Set type name

Source

pub fn with_source_file(self, file: String) -> Self

Set source file path

Source

pub fn with_source_line(self, line: u32) -> Self

Set source line number

Source

pub fn with_call_stack_hash(self, hash: u64) -> Self

Set call stack hash

Source

pub fn with_thread_name(self, name: String) -> Self

Set thread name

Source

pub fn is_allocation(&self) -> bool

Check if this is an allocation event

Source

pub fn is_deallocation(&self) -> bool

Check if this is a deallocation event

Source

pub fn is_move(&self) -> bool

Check if this is a move event

Source

pub fn is_borrow(&self) -> bool

Check if this is a borrow event

Source

pub fn is_return(&self) -> bool

Check if this is a return event

Trait Implementations§

Source§

impl Clone for MemoryEvent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryEvent

Source§

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

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

impl<'de> Deserialize<'de> for MemoryEvent

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 From<&MemoryEvent> for DashboardEventDTO

Source§

fn from(e: &MemoryEvent) -> Self

Converts to this type from the input type.
Source§

impl Serialize for MemoryEvent

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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