Search View vs. Search Editor for large dataset navigation
0 reputation · 04 Jun 2020, 09:40 UTC
0 reputation · 04 Jun 2020, 09:40 UTC
When performing a regex search across a large monorepo in Visual Studio Code, there is a distinct trade-off between using the standard Search View and the Search Editor. The Search View utilizes a virtualized list to stream results incrementally, which minimizes initial memory overhead during navigation.
Conversely, the Search Editor generates a persistent document of all matches. While this allows for saving the results as a file for curation or refactoring, it introduces potential memory pressure as the result set grows.
For a dataset containing tens of thousands of matches, it is unclear at what threshold the Search Editor's document-based approach becomes a performance bottleneck compared to the Search View's paginated streaming.
34775 reputation · 04 Jun 2020, 11:04 UTC
When the number of matches exceeds what your machine can comfortably hold in RAM, Search View is the safer, more efficient choice. It keeps only a small, virtualized slice of the result list in memory, so navigation stays responsive even for millions of matches. The Search Editor builds a single document that grows linearly with the match count; it has no internal pagination or virtualization, so it can quickly exhaust memory and trigger OS swapping or VS Code crashes.
matches × average_match_length. The editor’s document model holds all lines in memory, so the process memory grows linearly with the match set.maxResults filter or narrow the search scope to keep the file size manageable.No. The Search Editor’s document model holds all lines in memory; there is no internal pagination or lazy loading. The entire list is rendered by the editor, which means memory consumption is directly proportional to the number of matches.
Help → Toggle Developer Tools → Performance and record a timeline while scrolling through the results.To fine‑tune the threshold for your specific environment, it helps to know the amount of free RAM available when you run the search. If you can provide that figure, we can give a more precise recommendation on the safe match‑count limit for the Search Editor on your machine.
Use comments to ask for clarification. Post a solution as an answer.
5,560 reputation · 04 Jun 2020, 18:06 UTC
The Search View keeps only a small window of results in the DOM. It streams additional matches on demand from the ripgrep backend. Because it renders just the visible items, the memory footprint stays low even if the total match count is in the hundreds of thousands.
The Search Editor materializes every match into a single TextDocument. The editor’s internal buffer grows linearly with the number of results and the size of each preview line. This means that, for very large result sets, the editor can consume significant RAM and may trigger the “large‑file” heuristics (e.g., >100 MB) or even crash.
To verify the behavior on your machine, run a regex that matches a common character (e.g., e) across a large repo, then monitor the process memory in Task Manager or Activity Monitor while scrolling. You’ll typically see the Search View’s memory stay flat, whereas the Search Editor’s memory climbs steadily.