Struct mnemos_alloc::heap::State

source ·
#[non_exhaustive]
pub struct State { pub allocating: u16, pub deallocating: u16, pub is_oom: bool, pub total_bytes: usize, pub allocated_bytes: usize, pub alloc_success_count: usize, pub alloc_oom_count: usize, pub dealloc_count: usize, }
Available on crate feature stats only.
Expand description

A snapshot of the current state of the heap.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§allocating: u16

A count of the total number of concurrently executing calls to alloc().

If this is 0, no CPU cores are currently allocating.

§deallocating: u16

A count of the total number of concurrently executing calls to dealloc().

If this is 0, no CPU cores are currently allocating.

§is_oom: bool

If this is true, an allocation request could not be satisfied because there was insufficient memory. That allocation request may be queued.

§total_bytes: usize

The total size of the heap, in bytes. This includes memory that is currently allocated.

§allocated_bytes: usize

The amount of memory currently allocated, in bytes.

§alloc_success_count: usize

The total number of times an allocation attempt has succeeded, over the lifetime of this heap.

§alloc_oom_count: usize

The total number of times an allocation attempt could not be fulfilled because there was insufficient space, over the lifetime of this heap.

§dealloc_count: usize

The total number of times an allocation has been freed, over the lifetime of this heap.

Implementations§

source§

impl State

source

pub fn free_bytes(&self) -> usize

Returns the current amount of free space in the heap, in bytes.

This is calculated by subtracting [self.allocated_bytes] from [self.total_bytes].

source

pub fn alloc_attempt_count(&self) -> usize

Returns the total number of allocation attempts that have been requested from this heap (successes or failures).

This is the sum of [self.alloc_success_count] and [self.alloc_oom_count].

source

pub fn live_alloc_count(&self) -> usize

Returns the number of currently “live” allocations at the current point in time.

This is calculated by subtracting [self.dealloc_count] (the number of allocations which have been freed) from [self.alloc_success_count] (the total number of allocations).

Trait Implementations§

source§

impl Clone for State

source§

fn clone(&self) -> State

Returns a copy 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 State

source§

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

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

impl Copy for State

Auto Trait Implementations§

§

impl Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnwindSafe for State

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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,

§

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>,

§

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>,

§

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