siddharthmittal13 opened a new issue, #589: URL: https://github.com/apache/avro-rs/issues/589
### Problem/motivation `apache-avro` currently offers no first-class hook for customizing or observing heap allocation. The existing `util::max_allocation_bytes` guard only rejects a single oversized length prefix at decode time; it gives no visibility into the actual live/peak memory a workload uses, and no reusable building block for users who want to plug in custom allocation behavior. ### Proposed solution Add an **opt-in** cargo feature `custom_allocator` (off by default) exposing a new `apache_avro::alloc` module with two custom `GlobalAlloc` implementations: 1. **`CustomAllocator`** — a minimal allocator that delegates to the `System` allocator. A ready-made base users can install as `#[global_allocator]` or extend to add their own behavior (logging, pooling, etc.) without reimplementing platform allocation logic. 2. **`CountingAllocator<A = System>`** — wraps any inner allocator and tracks live bytes (`allocated()`), peak (`peak_allocated()`), cumulative (`total_allocated()`), and allocation/deallocation counts, with `reset_peak()` for scoped measurement. `const fn` constructors let it back a `#[global_allocator]` static. Both are opt-in and inert unless the user installs one as the global allocator, so there is zero impact when the feature is disabled. `CountingAllocator` complements `max_allocation_bytes` by measuring real process memory, including pressure from many individually-small allocations. ### Alternatives considered - A plain user-side `#[global_allocator]`: works, but every user must re-implement the counting/peak logic; std provides no counting allocator. - Re-exporting a third-party allocator (jemalloc/mimalloc): low novelty and users can already do that themselves. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
