Skip to content

Arena::Drop leaks memory by failing to invoke destructors of GC objects #20

@Ironankit525

Description

@Ironankit525

When MarkSweepGarbageCollector is dropped (or an Arena drops normally), the destructor for Arena handles the primary byte buffer by calling dealloc(self.buffer, self.layout). Unfortunately, it does not explicitly walk the allocations within the Arena to trigger their respective destructors (drop_in_place).

While basic memory within the arena gets cleaned up, if the GC wrapper contains unmanaged heap data (e.g. String, Vec, or structs managing system resources), those drop routines will never be invoked, severely leaking memory.

Proposed Solution: Update impl Drop for Arena (or perform it before dropping in MarkSweepGarbageCollector) to iterate through the self.last_allocation singly-linked list. For any ArenaHeapItem where !item.is_dropped(), explicitly invoke item.drop() or drop_in_place before finally deallocating the underlying arena buffer.

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