Skip to content

[Bug] Performance: In-place BoundedMap Update Causes High Allocation #894

Description

@akramcodez

Description

useAppState.tsx:265-275 allocates a new BoundedMap on every miss by making a full copy of existing entries, which is inefficient and triggers unnecessary garbage collection.

Environment

  • OS: Any
  • Node version: Node 22+
  • Nanocoder version: 1.29.0
  • Provider: Any
  • Model: Any

Steps to Reproduce

  1. Run Nanocoder in interactive mode.
  2. Perform operations that frequently miss the BoundedMap cache.
  3. Profile memory allocations.

Expected Behavior

The map should update in-place, perhaps by tracking the oldest entry via an insertion counter.

Actual Behavior

A new BoundedMap is allocated on every miss.

Logs/Screenshots

N/A

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • I can reproduce this issue consistently
  • This issue occurs with the latest version of nanocoder and feat

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions