pub trait MallocSizeOf {
    fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize;

    fn constant_size() -> Option<usize>
    where
        Self: Sized
, { ... } }
Expand description

Trait for measuring the “deep” heap usage of a data structure. This is the most commonly-used of the traits.

Required Methods§

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself. If T::size_of is a constant, consider implementing constant_size as well.

Provided Methods§

Used to optimize MallocSizeOf implementation for collections like Vec and HashMap to avoid iterating over them unnecessarily. The Self: Sized bound is for object safety.

Implementations on Foreign Types§

If a mutex is stored directly as a member of a data type that is being measured, it is the unique owner of its contents and deserves to be measured.

If a mutex is stored inside of an Arc value as a member of a data type that is being measured, the Arc will not be automatically measured so there is no risk of overcounting the mutex’s contents.

The same reasoning applies to RwLock.

Implementors§

impl<H, KF, T, M> MallocSizeOf for MemoryDB<H, KF, T, M>where
    H: KeyHasher,
    H::Out: MallocSizeOf,
    T: MallocSizeOf,
    KF: KeyFunction<H>,
    KF::Key: MallocSizeOf,
    M: MemTracker<T>,

impl<BlockNumber> MallocSizeOf for InboundDownwardMessage<BlockNumber>where
    BlockNumber: MallocSizeOf,

impl<BlockNumber> MallocSizeOf for InboundHrmpMessage<BlockNumber>where
    BlockNumber: MallocSizeOf,

impl<Id> MallocSizeOf for OutboundHrmpMessage<Id>where
    Id: MallocSizeOf,

impl MallocSizeOf for Id

impl<H> MallocSizeOf for CandidateDescriptor<H>where
    H: MallocSizeOf,

impl<H> MallocSizeOf for CandidateReceipt<H>where
    H: MallocSizeOf,

impl<H> MallocSizeOf for CommittedCandidateReceipt<H>where
    H: MallocSizeOf,

impl<H, N> MallocSizeOf for PersistedValidationData<H, N>where
    H: MallocSizeOf,
    N: MallocSizeOf,

impl<N> MallocSizeOf for CandidateCommitments<N>where
    N: MallocSizeOf,

impl<N> MallocSizeOf for GroupRotationInfo<N>where
    N: MallocSizeOf,

impl<H, N> MallocSizeOf for OccupiedCore<H, N>where
    H: MallocSizeOf,
    N: MallocSizeOf,

impl<H, N> MallocSizeOf for CoreState<H, N>where
    H: MallocSizeOf,
    N: MallocSizeOf,

impl<H> MallocSizeOf for CandidateEvent<H>where
    H: MallocSizeOf,

impl<H> MallocSizeOf for ScrapedOnChainVotes<H>where
    H: MallocSizeOf + Encode + Decode,

impl<B: ChainApi> MallocSizeOf for Pool<B>where
    <<B as ChainApi>::Block as Block>::Extrinsic: MallocSizeOf,

impl<Hash, Extrinsic> MallocSizeOf for Transaction<Hash, Extrinsic>where
    Hash: MallocSizeOf,
    Extrinsic: MallocSizeOf,

impl<PoolApi, Block> MallocSizeOf for BasicPool<PoolApi, Block>where
    PoolApi: ChainApi<Block = Block>,
    Block: BlockT,

impl<Header, Extrinsic> MallocSizeOf for Block<Header, Extrinsic>where
    Header: MallocSizeOf,
    Extrinsic: MallocSizeOf + MaybeSerialize,

impl<Number, Hash> MallocSizeOf for Header<Number, Hash>where
    Number: Copy + Into<U256> + TryFrom<U256> + MallocSizeOf,
    Hash: HashT,
    Hash::Output: MallocSizeOf,

impl<Address, Call, Signature, Extra> MallocSizeOf for UncheckedExtrinsic<Address, Call, Signature, Extra>where
    Extra: SignedExtension,

impl<Xt> MallocSizeOf for ExtrinsicWrapper<Xt>where
    Xt: MallocSizeOf,

impl<Xt> MallocSizeOf for Block<Xt>where
    Xt: MallocSizeOf,

impl<Call, Extra> MallocSizeOf for TestXt<Call, Extra>