Skip to content

Memory Optimization Proposal: Shared Collector for Multi-HashMap Structures #66

@anonymous5l

Description

@anonymous5l

When implementing structures containing multiple HashMap instances, the current separate Collector allocation pattern introduces significant memory overhead.

// Current implementation (high memory cost)
struct Heavy {
    state1: HashMap<i32, i32>,  // Each has its own Collector
    ...
    state10: HashMap<i32, i32>
}
// Proposed implementation (shared collector)
struct Heavy {
    collector: Arc<Collector>,  // Shared reference
    state1: HashMap<i32, i32>,
    ...
    state10: HashMap<i32, i32>
}

// Reclaim by who owned `Collector`
impl Drop for Heavy {
    fn drop(&mut self) {
        unsafe { self.collector.reclaim_all() }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions