171 releases (21 breaking)

new 0.23.0-alpha.2 Apr 10, 2025
0.22.1 Feb 20, 2025
0.21.0 Dec 18, 2024
0.20.2 Nov 28, 2024
0.4.0 Mar 28, 2023

#141 in Memory management

Download history 3604/week @ 2024-12-22 3566/week @ 2024-12-29 5857/week @ 2025-01-05 7289/week @ 2025-01-12 6387/week @ 2025-01-19 6041/week @ 2025-01-26 7312/week @ 2025-02-02 5444/week @ 2025-02-09 6422/week @ 2025-02-16 7164/week @ 2025-02-23 11186/week @ 2025-03-02 14649/week @ 2025-03-09 12129/week @ 2025-03-16 11454/week @ 2025-03-23 9888/week @ 2025-03-30 12993/week @ 2025-04-06

47,334 downloads per month
Used in 69 crates (8 directly)

MIT/Apache

130KB
2K SLoC

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.


Run-time memory tracking and profiling.

Part of the rerun family of crates.

Latest version Documentation MIT Apache

This is a library for tracking memory use in a running application. This is useful for tracking leaks, and for figuring out what is using up memory.

re_memory includes an opt-in sampling profiler for allocation callstacks. Each time memory is allocated there is a chance a callstack will be collected. This information is tracked until deallocation. You can thus get information about what callstacks lead to the most live allocations, giving you a very useful memory profile of your running app, with minimal overhead.

Dependencies

~2–28MB
~381K SLoC