/// Describes an allocation in the [`AllocatorReport`]. #[derive(Clone)] pubstruct AllocationReport { /// The name provided to the `allocate()` function. pub name: String, /// The offset in bytes of the allocation in its memory block. pub offset: u64, /// The size in bytes of the allocation. pub size: u64, #[cfg(feature = "visualizer")] pub(crate) backtrace: Arc<Backtrace>,
}
/// Describes a memory block in the [`AllocatorReport`]. #[derive(Clone)] pubstruct MemoryBlockReport { /// The size in bytes of this memory block. pub size: u64, /// The range of allocations in [`AllocatorReport::allocations`] that are associated /// to this memory block. pub allocations: Range<usize>,
}
/// A report that can be generated for informational purposes using `Allocator::generate_report()`. #[derive(Clone)] pubstruct AllocatorReport { /// All live allocations, sub-allocated from memory blocks. pub allocations: Vec<AllocationReport>, /// All memory blocks. pub blocks: Vec<MemoryBlockReport>, /// Sum of the memory used by all allocations, in bytes. pub total_allocated_bytes: u64, /// Sum of the memory reserved by all memory blocks including unallocated regions, in bytes. pub total_reserved_bytes: u64,
}
impl fmt::Debug for AllocationReport { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let name = if !self.name.is_empty() { self.name.as_str()
} else { "--"
};
write!(f, "{name:?}: {}", fmt_bytes(self.size))
}
}
/// Helper function: reports if the suballocator is empty (meaning, having no allocations). #[must_use] fn is_empty(&self) -> bool { self.allocated() == 0
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.