Skip to content

analysis server consumes significant memory when VS Code restores a dirty file buffer for a project that no longer exists #4280

Closed

Description

@zinface

i open my computer, and vscode , in 3 minutes , have one nosave dart code in editor(old). so , my memory always been rising.

i have a picture!

image

After a while:

image

Activity

  1. zinface commented on Nov 23, 2022

    @zinface
    Author

    in /tmp/tmp.xxxx(code \mktemp -d``) workspace, i edit a file . now restart my computer/vscode, Vscode has an unsaved file.. top.

  2. DanTup commented on Nov 23, 2022

    @DanTup
    Member

    Can you run code --status while the memory usage is high and post the full output here?

  3. added
    awaiting infoRequires more information from the customer to progress
    on Nov 23, 2022
  4. zinface commented on Nov 23, 2022

    @zinface
    Author

    I can explain the recurrence steps of this problem hand in hand:

    • my environment is Deepin Linux.

      zinface@zinface-PC:~$ neofetch 
                   ............                zinface@zinface-PC 
               .';;;;;.       .,;,.            ------------------ 
            .,;;;;;;;.       ';;;;;;;.         OS: Deepin 20.7.1 x86_64 
          .;::::::::'     .,::;;,''''',.       Kernel: 5.15.45-amd64-desktop 
         ,'.::::::::    .;;'.          ';      Uptime: 5 hours, 5 mins 
        ;'  'cccccc,   ,' :: '..        .:     Packages: 2316 (dpkg) 
       ,,    :ccccc.  ;: .c, '' :.       ,;    Shell: bash 5.0.3 
      .l.     cllll' ., .lc  :; .l'       l.   Resolution: 2560x1440 
      .c       :lllc  ;cl:  .l' .ll.      :'   DE: Deepin 
      .l        'looc. .   ,o:  'oo'      c,   WM: KWin 
      .o.         .:ool::coc'  .ooo'      o.   Theme: deepin [GTK2/3] 
       ::            .....   .;dddo      ;c    Icons: bloom-classic [GTK2/3] 
        l:...            .';lddddo.     ,o     Terminal: deepin-terminal 
         lxxxxxdoolllodxxxxxxxxxc      :l      CPU: Intel Xeon E5-2680 v2 (20) @ 3.600GHz 
          ,dxxxxxxxxxxxxxxxxxxl.     'o,       GPU: NVIDIA GeForce GTX 750 
            ,dkkkkkkkkkkkkko;.    .;o;         Memory: 20768MiB / 32033MiB 
              .;okkkkkdl;.    .,cl:.
                  .,:cccccccc:,.                                       
      
      zinface@zinface-PC:~$ 
    • Let's reproduce the problem.

      The following is described in the window with only one VSCode instance.

      1. You use mktemp -d or any other method to create a temporary folder, which we will delete later.

        This is a way to simulate the use of memory space (tmpfs) or to create temporary engineering projects under /tmp.

      2. You go to the folder and use dart create dart_project to create a dart project and open it using VSCode.

      3. You find a dart file that exists in the project to edit it, but you do not save it, so we will directly close VSCode.

      4. We delete the temporary directory in this step and simulate that the contents in the tmpfs are emptied after restart.

      5. We open VSCode again, and VSCode will try to open the project before the last instance was closed.

        Because we have deleted the folder, there is only one unsaved dart file in the window.

        At this time, I found that the memory footprint on my machine was rising.

    Above, I use machine translation to explain the problem.

  5. zinface commented on Nov 23, 2022

    @zinface
    Author

    Can you run code --status while the memory usage is high and post the full output here?

    Reply: information from code --status

    The following is the information when memory usage is 20%, 40%, 60%, 80%, respectively.

    NOTE: Note that I didn't find much difference when I compared the contents of three files using the meld tool.

    • Memory 20%(It just started.)

      [144190:1124/013627.579366:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
      [144232:1124/013627.702708:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [144232:1124/013627.702826:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264Main and entrypoint VAEntrypointVLD
      [144232:1124/013627.702897:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [144232:1124/013627.702948:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264High and entrypoint VAEntrypointVLD
      Version:          Code 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-01T15:44:09.336Z)
      OS Version:       Linux x64 5.15.45-amd64-desktop
      CPUs:             Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz (20 x 2742)
      Memory (System):  31.28GB (24.92GB free)
      Load (avg):       2, 1, 1
      VM:               0%
      Screen Reader:    no
      Process Argv:     --unity-launch --crash-reporter-id b18b9af0-f391-4c91-bc45-47c3cd02136c
      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:                           disabled_software
                      video_encode:                           disabled_software
                      vulkan:                                 disabled_off
                      webgl:                                  enabled
                      webgl2:                                 enabled
                      webgpu:                                 disabled_off
      
      CPU %   Mem MB     PID  Process
          0      128  143481  code main
          0       32  143484     zygote
          0      128  143517       gpu-process
          0        0  143525         broker
          0       32  143485     zygote
          0        0  143487       zygote
          0       32  143523     utility-network-service
          0      224  143541     window (● file_demo.dart - Visual Studio Code)
          0      128  143617     shared-process
          0       64  143655       ptyHost
          0       64  143697       fileWatcher
          0      160  143631     extensionHost
          0        0  143714       /bin/sh -c "/home/zinface/deploy/flutter-sdk/bin/cache/dart-sdk/bin/dart" "language-server" "--protocol=lsp" "--client-id=VS-Code" "--client-version=3.52.1"
          0        0  143720       /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0
          0       96  143773         /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0 --no_bootstrap
          0       64  143923       /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=143631
      
    • Memory 40%

      zinface@zinface-PC:~$ code --status
      [144540:1124/013736.827345:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
      [144576:1124/013737.016947:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [144576:1124/013737.017067:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264Main and entrypoint VAEntrypointVLD
      [144576:1124/013737.017127:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [144576:1124/013737.017173:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264High and entrypoint VAEntrypointVLD
      Version:          Code 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-01T15:44:09.336Z)
      OS Version:       Linux x64 5.15.45-amd64-desktop
      CPUs:             Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz (20 x 2800)
      Memory (System):  31.28GB (18.22GB free)
      Load (avg):       2, 1, 1
      VM:               0%
      Screen Reader:    no
      Process Argv:     --unity-launch --crash-reporter-id b18b9af0-f391-4c91-bc45-47c3cd02136c
      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:                           disabled_software
                      video_encode:                           disabled_software
                      vulkan:                                 disabled_off
                      webgl:                                  enabled
                      webgl2:                                 enabled
                      webgpu:                                 disabled_off
      
      CPU %   Mem MB     PID  Process
          0      128  143481  code main
          0       32  143484     zygote
          0      128  143517       gpu-process
          0        0  143525         broker
          0       32  143485     zygote
          0        0  143487       zygote
          0       32  143523     utility-network-service
          0      192  143541     window (● file_demo.dart - Visual Studio Code)
          0      128  143617     shared-process
          0       64  143655       ptyHost
          0       64  143697       fileWatcher
          0      128  143631     extensionHost
          0        0  143714       /bin/sh -c "/home/zinface/deploy/flutter-sdk/bin/cache/dart-sdk/bin/dart" "language-server" "--protocol=lsp" "--client-id=VS-Code" "--client-version=3.52.1"
          0        0  143720       /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0
          0       96  143773         /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0 --no_bootstrap
          0       64  143923       /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=143631
      
    • Memory 60%

      zinface@zinface-PC:~$ code --status
      [144815:1124/013840.961003:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
      [144851:1124/013841.105395:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [144851:1124/013841.105516:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264Main and entrypoint VAEntrypointVLD
      [144851:1124/013841.105584:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [144851:1124/013841.105643:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264High and entrypoint VAEntrypointVLD
      Version:          Code 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-01T15:44:09.336Z)
      OS Version:       Linux x64 5.15.45-amd64-desktop
      CPUs:             Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz (20 x 2708)
      Memory (System):  31.28GB (11.99GB free)
      Load (avg):       2, 1, 1
      VM:               0%
      Screen Reader:    no
      Process Argv:     --unity-launch --crash-reporter-id b18b9af0-f391-4c91-bc45-47c3cd02136c
      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:                           disabled_software
                      video_encode:                           disabled_software
                      vulkan:                                 disabled_off
                      webgl:                                  enabled
                      webgl2:                                 enabled
                      webgpu:                                 disabled_off
      
      CPU %   Mem MB     PID  Process
          0      128  143481  code main
          0       32  143484     zygote
          0      128  143517       gpu-process
          0        0  143525         broker
          0       32  143485     zygote
          0        0  143487       zygote
          0       32  143523     utility-network-service
          0      224  143541     window (● file_demo.dart - Visual Studio Code)
          0      128  143617     shared-process
          0       64  143655       ptyHost
          0       64  143697       fileWatcher
          0      128  143631     extensionHost
          0        0  143714       /bin/sh -c "/home/zinface/deploy/flutter-sdk/bin/cache/dart-sdk/bin/dart" "language-server" "--protocol=lsp" "--client-id=VS-Code" "--client-version=3.52.1"
          0        0  143720       /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0
          0       96  143773         /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0 --no_bootstrap
          0       64  143923       /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=143631
      
      
    • Memory 80%

      zinface@zinface-PC:~$ code --status
      [145098:1124/013945.163195:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
      [145133:1124/013945.292956:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [145133:1124/013945.293073:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264Main and entrypoint VAEntrypointVLD
      [145133:1124/013945.293136:ERROR:vaapi_wrapper.cc(1131)] vaQuerySurfaceAttributes failed, VA error: invalid parameter
      [145133:1124/013945.293181:ERROR:vaapi_wrapper.cc(1078)] FillProfileInfo_Locked failed for va_profile VAProfileH264High and entrypoint VAEntrypointVLD
      Version:          Code 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-01T15:44:09.336Z)
      OS Version:       Linux x64 5.15.45-amd64-desktop
      CPUs:             Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz (20 x 1400)
      Memory (System):  31.28GB (5.86GB free)
      Load (avg):       3, 2, 1
      VM:               0%
      Screen Reader:    no
      Process Argv:     --unity-launch --crash-reporter-id b18b9af0-f391-4c91-bc45-47c3cd02136c
      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:                           disabled_software
                      video_encode:                           disabled_software
                      vulkan:                                 disabled_off
                      webgl:                                  enabled
                      webgl2:                                 enabled
                      webgpu:                                 disabled_off
      
      CPU %   Mem MB     PID  Process
          0       96  143481  code main
          0        0  143484     zygote
          0      128  143517       gpu-process
          0        0  143525         broker
          0        0  143485     zygote
          0        0  143487       zygote
          0       32  143523     utility-network-service
          0      192  143541     window (● file_demo.dart - Visual Studio Code)
          0       96  143617     shared-process
          0       32  143655       ptyHost
          0       32  143697       fileWatcher
          0       96  143631     extensionHost
          0        0  143714       /bin/sh -c "/home/zinface/deploy/flutter-sdk/bin/cache/dart-sdk/bin/dart" "language-server" "--protocol=lsp" "--client-id=VS-Code" "--client-version=3.52.1"
          0        0  143720       /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0
          0       96  143773         /home/zinface/.config/Code/User/globalStorage/tabnine.tabnine-vscode/binaries/4.4.186/x86_64-unknown-linux-musl/TabNine --client=vscode --no-lsp=true --client-metadata clientVersion=1.73.0 pluginVersion=3.6.23 t9-vscode-AutoImportEnabled=true t9-vscode-TSAutoImportEnabled=true t9-vscode-JSAutoImportEnabled=true vscode-telemetry-enabled=true vscode-remote=false vscode-remote-name=undefined vscode-extension-kind=1 vscode-theme-name=One Dark Pro vscode-theme-kind=Dark vscode-machine-id=c978ebde2bcfb69187da13850ec3f9cbbd947872615ab9494b612105210543b6 vscode-is-new-app-install=false vscode-session-id=c6e12a68-e76e-4066-80d6-92a815c74daf1669224970022 vscode-language=zh-cn vscode-app-name=Visual Studio Code vscode-beta-channel-enabled=false vscode-status-customization=unknown ide-restart-counter=0 --no_bootstrap
          0       32  143923       /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=143631
      
      
  6. zinface commented on Nov 23, 2022

    @zinface
    Author

    Above, I use machine translation to explain the problem.

    I also repeated this question when I turned off all plug-ins and opened only one Dart plug-in.

  7. DanTup commented on Nov 23, 2022

    @DanTup
    Member

    @zinface thanks for the detailed steps. Unfortunately I haven't been able to reproduce it (although I'm on macOS, I don't know if that's a factor).

    Is it possible you can set the analyzer instrumentation log in your VS Code User Settings:

    https://dartcode.org/docs/logging/#analyzer-instrumentation

    "dart.analyzerInstrumentationLogFile": "/path/to/log.txt"

    And then reproduce the issue, and see whether this log file is being written to as the memory usage is growing? You can attach the log or email it to me at [email protected] if it's not too big (but please reproduce this with a small sample app, because the log may contain parts of source code from the open files).

    Thanks!

  8. zinface commented on Nov 24, 2022

    @zinface
    Author

    @zinface thanks for the detailed steps. Unfortunately I haven't been able to reproduce it (although I'm on macOS, I don't know if that's a factor).

    Is it possible you can set the analyzer instrumentation log in your VS Code User Settings:

    https://dartcode.org/docs/logging/#analyzer-instrumentation

    "dart.analyzerInstrumentationLogFile": "/path/to/log.txt"

    And then reproduce the issue, and see whether this log file is being written to as the memory usage is growing? You can attach the log or email it to me at [email protected] if it's not too big (but please reproduce this with a small sample app, because the log may contain parts of source code from the open files).

    Thanks!

    I have e-mailed the information you mentioned, along with about 2 minutes of screenshot files (reproducing the problem).

  9. DanTup commented on Nov 28, 2022

    @DanTup
    Member

    @zinface thank you for the detailed video and logs! I think I see what's going on. When VS Code is opened with that unsaved file, the server tries to create a watcher for it - however the file does not exist on disk and this causes an error:

    1669305711347:Err:Temporary watcher error; restarting context build.
    FileSystemException:: Failed to watch path, path = '/tmp/tmp.75uS4AnOM4/file_demo/bin/file_demo.dart' (OS Error:: No such file or directory, errno = 2)
    
    1669305711437:Err:Watcher error; refreshing contexts.
    FileSystemException:: Failed to watch path, path = '/tmp/tmp.75uS4AnOM4/file_demo/bin/file_demo.dart' (OS Error:: No such file or directory, errno = 2)
    
    1669305711439:Err:Temporary watcher error; restarting context build.
    FileSystemException:: Failed to watch path, path = '/tmp/tmp.75uS4AnOM4/file_demo/bin/file_demo.dart' (OS Error:: No such file or directory, errno = 2)
    

    This server interprets this error as something it can recover from, so it tries again. And it keeps retrying repeatedly forever.

    I'm not certain why the memory usage climbs so high, but now I understand the cause I might have better luck reproducing it so I can work on a fix. Thanks!

  10. added
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    and removed
    awaiting infoRequires more information from the customer to progress
    on Nov 28, 2022
  11. added this to the v3.56.0 milestone on Nov 28, 2022
  12. changed the title [-]Oh, My Computer is Die! Memory Done.[/-] [+]analysis server consumes significant memory when VS Code restores a dirty file buffer for a project that no longer exists[/+] on Nov 30, 2022
  13. DanTup commented on Dec 12, 2022

    @DanTup
    Member

    @zinface sorry for the delay. I'm working in this now but struggling to reproduce (even on Linux). The attachment links in you email have now expired - do you still have a copy you can re-send to me to [email protected] so I can understand what's different between my setup and yours? Thanks!

  14. modified the milestones: v3.56.0, v3.58.0 on Dec 14, 2022
  15. zinface commented on Dec 17, 2022

    @zinface
    Author

    @zinface sorry for the delay. I'm working in this now but struggling to reproduce (even on Linux). The attachment links in you email have now expired - do you still have a copy you can re-send to me to [email protected] so I can understand what's different between my setup and yours? Thanks!

    I just saw the email now. Of course, it's already the weekend. I have re-sent the content I prepared last time.

  16. zinface commented on Dec 17, 2022

    @zinface
    Author

    In addition, I have prepared a shorter video to provide a clearer review process.

  17. DanTup commented on Dec 19, 2022

    @DanTup
    Member

    @zinface thank you - I got the files and they are attached to the email this time, so there is no danger of them expiring :)

    I'm out of the office for a little over Christmas, but I will try to get to the bottom of this in the new year. Thanks!

  18. modified the milestones: v3.58.0, v3.60.0 on Jan 17, 2023
  19. DanTup commented on Feb 21, 2023

    @DanTup
    Member

    Sorry for the delay. I've been able to reproduce this in an Ubuntu VM. I'm not sure exactly what's going on yet, but will do some digging.

    For my future reference, here's a log file that has some additional logging from running the server from source in the VM.

    instrum.txt

  20. DanTup commented on Feb 21, 2023

    @DanTup
    Member

    Ok, I have a better idea of what's happening now. In the log there are two sets of errors alternating:

    1676999680132:Err:Temporary watcher error; restarting context build.
    PathNotFoundException:: Failed to watch path, path = '/home/danny/Desktop/deleteme/deleteme2/foo.dart' (OS Error:: No such file or directory, errno = 2)
    1676999680153:Err:Watcher error; refreshing contexts.
    PathNotFoundException:: Failed to watch path, path = '/home/danny/Desktop/deleteme/deleteme2/foo.dart' (OS Error:: No such file or directory, errno = 2)
    

    The first error ("Temporary watcher error") is the one we're handling while trying to build the context roots. We will try up to 5 times before giving up.

    The second error is code that tries to handle errors generally and triggers a context rebuild. It's this one that's causing the rebuilds to occur in a loop, not the original "temporary watcher" one (but because it triggers a rebuild, it causes that code to run again, and the error to be logged).

    I think there may be a difference in how these errors occur on Linux versus other platforms which is why it's only seen here, although it seems like we should detect if we get into a situation where we're endlessly trying to rebuild contexts (they're likely failing for a reason that isn't going to change if we try again).

    Two thoughts:

    1. If we seem to be endlessly rebuilding contexts, shut down with an error messages
    2. Detect when we're failing to set up a watcher because the folder doesn't exist, and handle it differently (in this case, not creating the watcher would be better - and perhaps what's happening on other platforms?).. although we won't handle the case where that folder is re-created - but I think we may already not handle this correctly in some cases.
  21. DanTup commented on Feb 22, 2023

    @DanTup
    Member

    (@bwilkerson @scheglov FYI.. I think I have a fix for this, but some background for when you get the review..)

    I have a very easy way to reproduce what is essentially the same issue (it only occurs on Linux - there are some differences in how this kind of error is raised across platforms, I think it's been discussed before although I can't find the discussion):

    • run dart language-server --protocol=analyzer --instrumentation-log-file=/tmp/analyzer.txt
    • in another terminal, run tail -f /tmp/analyzer.txt
    • paste into the server process {"id": "1", "method": "analysis.setAnalysisRoots", "params": { "included": ["/home/not/existing"], "excluded": []}}

    You'll see the log file file up as we infinitely try to rebuild the analysis roots and consume a lot of resources.

    Although setting an analysis root to a non-existing directory is unlikely (though suspect deleting a valid root while the server is running will do the same), the original case here is where VS Code restores an unsaved file in a deleted directory at startup (for ex you had an open dirty file in /tmp and rebooted then re-opened VS Code) so we end up trying to create a root for it.

    The reason this occurs is that creating a watcher on a folder that doesn't exist emits an error on the stream (on Linux) and triggers this code that wants to restart (because a watcher error means we can't trust our state of the world):

    https://github.com/dart-lang/sdk/blob/8ef5104d05e2b43541a69640ac77b8619cb576f3/pkg/analysis_server/lib/src/context_manager.dart#L770-L777

    Rebuilding doesn't help because the same error will occur again, and we'll just sit in a loop doing this as fast as possible.

    My proposed fix is to skip that rebuild if (error is PathNotFoundException). We're not going to get anything useful from the watcher after the error, and rebuilding isn't going to give us anything more. I believe we document that we handle directories created later, but as far as I know that isn't working (package:watcher doesn't support supporting watching non-existing directories so supporting this would be complicated, and potentially expensive if we have to end up watching grandparent folders, potentially even the root?).

  22. DanTup commented on Feb 22, 2023

    @DanTup
    Member
  23. DanTup commented on Feb 28, 2023

    @DanTup
    Member

    This is fixed by dart-lang/sdk@e231f12. The change is in the Dart SDK, so will ship in a future Dart/Flutter release rather than a Dart-Code update.

  24. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions