Skip to content

NesXtabHistoryTracker stores many copies of really large documents #309246

@roblourens

Description

@roblourens

I took a heap snapshot of the EH after using chat for awhile. The heap was 2.1GB. Copilot analyzed the snapshot and said this

The largest retained self-size group is 19 giant string nodes totaling about 699.7 MB. Each string is about 37 MB and starts with a Copilot agent session transcript JSONL payload (`session.start`, `session.mode_changed`, `user.message`, etc.).

The representative string node retainer path is:

- 37 MB string containing the session transcript
- retained by an object property `value`
- retained by an object property `base`
- retained by an object property `edit`
- retained by arrays under property `xtabEditHistory`

This points to `NesXtabHistoryTracker`, which was bounded by entry count only (`MAX_HISTORY_SIZE = 50`) but each history entry could retain a full `StringText` base or visible-range document content. A large JSONL/log document edited while inline-edit history tracking is active can therefore be retained multiple times. In this snapshot, 19 history entries retained about 700 MB of duplicate large document text.

I had opened a really large events.jsonl from copilot and it seems like that is causing us to use a ton of memory in the EH

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions