Registry / testing / alloc-counter

alloc-counter

JSON →
library0.0.4rscratesunverified

Count, allow, deny, or forbid allocations on a per-expression or per-function basis for debugging.

# Cargo.toml [dependencies] alloc_counter = "0.0.4"
INSTALL
IMPORT
SIG · ALLOC-COUNTER
A
alloc-counter
testingrustv0.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AllocCounter
use alloc_counter::AllocCounter;

Create an allocation counter and measure allocations from a vector creation.

use alloc_counter::AllocCounter; fn main() { let counter = AllocCounter::new(); let _v = vec![1, 2, 3]; println!("Allocations: {}", counter.count()); }
Debug
Known issues
gotchaOnly works with the global allocator; may not catch all allocations in multi-threaded contexts.
fix
Use with #[global_allocator] and ensure single-threaded testing.
affects: >=0.0.4
Upgrade
Version history
0.0.4latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
50 hits · last 30 days
node
42
Meta
1
OpenAI (training)
1
Resources
alloc-counter — cargo add alloc-counter · libregistry