microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.86k stars 29.51k forks source link

Certain task output causes excessive memory use #155134

Open joshbolduc opened 2 years ago

joshbolduc commented 2 years ago

Type: Bug

Repro steps:

  1. Clone and open this reproduction repo (assumes node/npm installed and in your PATH): https://github.com/joshbolduc/vscode-task-memory-leak
  2. Run npm install
  3. Command palette -> run task -> start storybook -> continue without scanning the task output
  4. As soon as the task starts executing, shrink the terminal pane width so that the webpack output wraps. (There should be many lines of output printed rapidly; total output should be in the range of ~140,000 characters.)
  5. Observe memory usage of Code-related processes

Expect: Memory usage is reasonable, no crash

Actual: Memory usage rises rapidly and peaks at >2GB. Depending on task output, the window might crash due to OOM

For added context: I created the above repo based on an issue I encountered debugging an extension of mine. That extension creates a task using ProcessExecution that is similar to the task in the repo above. For whatever reason, on Windows, the task output when I create it via my extension always seems to wrap, resulting in many lines of output. (This is true even though, for the above repro, I have to shrink the window to induce the same behavior.) As a result, I see memory usage climb if I reveal the terminal being used to run the task. In my small test projects, this regularly results in an OOM crash.

This problem does not appear to happen:

VS Code version: Code - Insiders 1.70.0-insider (052d5b0027f6c9d64c8ca35955cb5117ba94d5d7, 2022-07-13T05:16:18.401Z) OS version: Windows_NT x64 10.0.19044 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (8 x 3411)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.71GB (3.82GB free)| |Process Argv|--crash-reporter-id 80d4f634-4fbe-40d1-8223-a2a5cb69e82f| |Screen Reader|no| |VM|29%|
Extensions: none
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30422396 pythontb:30258533 pythonptprofiler:30281269 vsdfh931:30280409 vshan820:30294714 pythondataviewer:30285072 vscod805:30301674 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30404738 wslgetstarted:30449409 vscscmwlcmt:30465136 cppdebug:30492333 pylanb8912:30522163 vsclangdf:30492506 ```
meganrogge commented 1 year ago

Thanks for the report, likely the same as https://github.com/microsoft/vscode/issues/174511