Skip to content

GcAllocator::allocate completely bypasses GC heap limits for external allocations #19

@Ironankit525

Description

@Ironankit525

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions