Crate re_memory

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

accounting_allocator
Track allocations and memory use.
util
Utitility functions

Structs§

CallstackStatistics
Per-callstack statistics.
CountAndSize
Number of allocation and their total size.
MemoryHistory
Tracks memory use over time.
MemoryLimit
Represents a limit in how much RAM to use for the entire process.
MemoryUse
How much RAM is the application using?
RamLimitWarner
Helper to warn if we are using too much RAM.
ReadableBacktrace
Formatted backtrace.

Functions§

total_ram_in_bytes
Amount of available RAM on this machine.