Expand description
Run-time memory tracking and profiling.
§First steps
Add re_memory
to your Cargo.toml
:
cargo add re_memory
Install the AccountingAllocator
in your main.rs
:
use re_memory::AccountingAllocator;
#[global_allocator]
static GLOBAL: AccountingAllocator<std::alloc::System>
= AccountingAllocator::new(std::alloc::System);
§Checking memory use
Use MemoryUse::capture
to get the current memory use of your application.
§Finding memory leaks
Turn on memory tracking at the top of your main()
function:
re_memory::accounting_allocator::set_tracking_callstacks(true);
Now let your app run for a while, and then call accounting_allocator::tracking_stats
to get the statistics. Any memory leak should show up in
TrackingStatistics::top_callstacks
.
§More
See also accounting_allocator
.
Re-exports§
pub use accounting_allocator::AccountingAllocator;
pub use accounting_allocator::TrackingStatistics;
Modules§
- Track allocations and memory use.
- Utitility functions
Structs§
- Per-callstack statistics.
- Number of allocation and their total size.
- Tracks memory use over time.
- Represents a limit in how much RAM to use for the entire process.
- How much RAM is the application using?
- Helper to warn if we are using too much RAM.
- Formatted backtrace.
Functions§
- Amount of available RAM on this machine.