microsoft / microsoft/vscode

## [Performance] Prevent OOM crashes by implementing LRU garbage collection in AsyncDataTree

Open
#332,420 1 comment 0 reactions 1 assignee Claimed by @benibenj View on GitHub
performance tree-widget
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

### The Problem
When opening massive workspaces (e.g., mono-repos with 500k+ files) or returning massive search results, expanding the Explorer tree causes the `AsyncDataTree` to materialize hundreds of thousands of nodes in memory.

Even though the DOM is virtualized via `listWidget.ts`, the in-memory metadata for these nodes scales linearly. Eventually, the browser engine exhausts its memory limit and the renderer crashes (**OOM**).

### The Solution
Implement an **LRU (Least Recently Used) cache** and aggressive garbage collection mechanism within `asyncDataTree.ts`.

When the total number of materialized nodes exceeds a safe threshold (e.g., 50,000), nodes that are not currently visible in the viewport and haven't been accessed recently should be:

- Automatically collapsed
- Garbage collected from memory

This ensures scalability and prevents renderer crashes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.