-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Currently, GcAllocator implements the Allocator trait and triggers collector.collect() when is_below_threshold() returns false. However, is_below_threshold() only monitors the allocated GC arenas length. Because GcAllocator handles memory by directly calling the global rust_alloc::alloc::alloc(layout) without adding to the arenas, arenas_len() never surpasses the threshold from these operations.
This leads to a silent logic bug where massive external allocations (like Vec instances backed by GcAllocator) will safely allocate gigabytes of system memory but will never trigger a garbage collection cycle.
Proposed Solution: Track external heap allocation size locally. Introduce an external_bytes counter to ArenaAllocator or MarkSweepGarbageCollector that increments on allocate and decrements on deallocate. Include this external_bytes tracker when determining if the GC is out of memory/above threshold.
Could you please assign this issue to me?