FsAutoComplete icon indicating copy to clipboard operation
FsAutoComplete copied to clipboard

Potential memory leak with Ionide F# Extension

Open gatinha96 opened this issue 3 months ago • 6 comments

Version

7.29.0

Dotnet Info

.NET SDK: Version: 9.0.200 Commit: 90e8b202f2 Workload version: 9.0.200-manifests.b4a8049f MSBuild version: 17.13.8+cbc39bea8

Runtime Environment: OS Name: Windows OS Version: 10.0.26100 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\9.0.200\

.NET workloads installed: There are no installed workloads to display. Configured to use loose manifests when installing new manifests.

Host: Version: 9.0.2 Architecture: x64 Commit: 80aa709f5d

.NET SDKs installed: 9.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: None

Environment variables: Not set

global.json file: Not found

Steps to reproduce

  • Have the Ionide F# Extension enabled
  • Open VS Code

Details

A .net host process originated from F# slowly climbs in memory usage until around 95% of total memory in usage.

Image Image

Expected behavior

Relatively stable memory usage on all processes.

Actual behavior

Observed a .net host process climbing up in memory usage, until around 95% total memory is being consumed.

Known workarounds

Disable Ionide F# extension.

Related information

I have first posted this issue on the C# extension github, then got redirected here as the process in question originates from F#.

Logs

Ionide

[10:02:55 DEBUG] [LanguageService] FSAC (NETCORE): 'c:\Users\user.vscode\extensions\ionide.ionide-fsharp-7.29.0\bin\net9.0\fsautocomplete.dll' [10:02:55 DEBUG] [LanguageService] F# language server options: % { command: 'C:\Program Files\dotnet\dotnet.exe', args: [ 'c:\Users\user\.vscode\extensions\ionide.ionide-fsharp-7.29.0\bin\net9.0\fsautocomplete.dll', '--state-directory', 'c:\Users\user\AppData\Roaming\Code\User\workspaceStorage\266cf77dd7a1ef7ddfb4ac365b9c3288\Ionide.Ionide-fsharp' ], options: { env: { ALLUSERSPROFILE: 'C:\ProgramData', APPDATA: 'C:\Users\user\AppData\Roaming', CHROME_CRASHPAD_PIPE_NAME: '\\.\pipe\crashpad_27896_TTSPWBZDFFQUHNJU', CommonPropertyBagPath: 'C:\Users\user\AppData\Local\Temp\csdevkit\035a05c3.json', CommonPropertyBagWithConfigPath: 'C:\Users\user\AppData\Local\Temp\csdevkit\f510f4d3fe4d1764756173087.json', COMPUTERNAME: 'CVIG-AM', ComSpec: 'C:\WINDOWS\system32\cmd.exe', CommonProgramFiles: 'C:\Program Files\Common Files', 'CommonProgramFiles(x86)': 'C:\Program Files (x86)\Common Files', CommonProgramW6432: 'C:\Program Files\Common Files', DADIR: 'C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common', DriverData: 'C:\Windows\System32\Drivers\DriverData', EFC_13664_1262719628: '1', EFC_13664_1592913036: '1', EFC_13664_2283032206: '1', EFC_13664_2775293581: '1', EFC_13664_3789132940: '1', ELECTRON_RUN_AS_NODE: '1', FPS_BROWSER_APP_PROFILE_STRING: 'Internet Explorer', FPS_BROWSER_USER_PROFILE_STRING: 'Default', HOMEDRIVE: 'C:', HOMEPATH: '\Users\user', IGCCSVC_DB: 'AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAcACg2HckyEyCXwgdnQYbWQQAAAACAAAAAAAQZgAAAAEAACAAAACtDIVEpuGgVq2sbi6nWvpRprjqTjeoNg1wW3D6RH4EuQAAAAAOgAAAAAIAACAAAABhFXsilDPacREFjyQtLv89+IhUfh6TIl37w8n0MLDkGmAAAACkMKZnel9KAxcj1xWVqVmHYmhNcet8ge1OymZsk1LOzdX+KdYjmYz0Zb53FVbDi2F2C0wKGk6wGuwjwIbjcyQ7GkRqwBlyVxureEM9GxwEuWAVdh2FyphIf+ANkm/RrApAAAAAeWyYCWXioooV8LldseEP5gUE9Y+pE9cq3ekKzEhiRWBvcAUW3RydYBLioWhPRUAm/feYQdPHLgTAIoI6HcTY5g==', LOCALAPPDATA: 'C:\Users\user\AppData\Local', LOGONSERVER: '\\DC2', NUMBER_OF_PROCESSORS: '32', ORIGINAL_XDG_CURRENT_DESKTOP: 'undefined', OS: 'Windows_NT', OneDrive: 'C:\Users\user\OneDrive - Instituto CCG ZGDV', OneDriveCommercial: 'C:\Users\user\OneDrive - Instituto CCG ZGDV', PATHEXT: '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC', PROCESSOR_ARCHITECTURE: 'AMD64', PROCESSOR_IDENTIFIER: 'Intel64 Family 6 Model 183 Stepping 1, GenuineIntel', PROCESSOR_LEVEL: '6', PROCESSOR_REVISION: 'b701', PSModulePath: 'C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules', PUBLIC: 'C:\Users\Public', Path: 'C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA app\NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Program Files\dotnet\;C:\Program Files\dotnet;C:\Program Files\dotnet\sdk-manifests\9.0.100;C:\Program Files\dotnet\sdk-manifests\8.0.100;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\user\.dotnet\tools;C:\Users\user\AppData\Local\Programs\Git\cmd', ProgramData: 'C:\ProgramData', ProgramFiles: 'C:\Program Files', 'ProgramFiles(x86)': 'C:\Program Files (x86)', ProgramW6432: 'C:\Program Files', SESSIONNAME: 'Console', SystemDrive: 'C:', SystemRoot: 'C:\WINDOWS', TEMP: 'C:\Users\ANDREI~1.MEN\AppData\Local\Temp', TMP: 'C:\Users\ANDREI~1.MEN\AppData\Local\Temp', USERDNSDOMAIN: 'CCG.LOCAL', USERDOMAIN: 'CCG', USERDOMAIN_ROAMINGPROFILE: 'CCG', USERNAME: 'user', USERPROFILE: 'C:\Users\user', VSCODE_CODE_CACHE_PATH: 'C:\Users\user\AppData\Roaming\Code\CachedData\bf9252a2fb45be6893dd8870c0bf37e2e1766d61', VSCODE_CRASH_REPORTER_PROCESS_TYPE: 'extensionHost', VSCODE_CWD: 'C:\Users\user\AppData\Local\Programs\Microsoft VS Code', VSCODE_DOTNET_INSTALL_TOOL_ORIGINAL_HOME: 'undefined', VSCODE_ESM_ENTRYPOINT: 'vs/workbench/api/node/extensionHostProcess', VSCODE_HANDLES_UNCAUGHT_ERRORS: 'true', VSCODE_IPC_HOOK: '\\.\pipe\bb357d2a-1.106.3-main-sock', VSCODE_NLS_CONFIG: '{"userLocale":"en-us","osLocale":"en-gb","resolvedLanguage":"en","defaultMessagesFile":"C:\\Users\\user\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\nls.messages.json","locale":"en-us","availableLanguages":{}}', VSCODE_PID: '27896', ZES_ENABLE_SYSMAN: '1', __COMPAT_LAYER: 'DetectorsAppHealth', tvdumpflags: '8', windir: 'C:\WINDOWS', DOTNET_GCNoAffinitize: 0, DOTNET_GCHeapCount: '0', DOTNET_GCConserveMemory: 0, DOTNET_GCServer: 1 } } } [10:02:57 DEBUG] [Main] Activating features

F#

[10:02:57 DEBUG] [TestExplorer] Extension Storage c:\Users\user\AppData\Roaming\Code\User\workspaceStorage\266cf77dd7a1ef7ddfb4ac365b9c3288\Ionide.Ionide-fsharp

Checklist

  • [x] I have looked through existing issues to make sure that this bug has not been reported before
  • [x] I have provided a descriptive title for this issue
  • [x] I have made sure that that this bug is reproducible on the latest version of the package
  • [x] I have provided all the information needed to reproduce this bug as efficiently as possible
  • [ ] I or my company would be willing to contribute this fix

gatinha96 avatar Dec 03 '25 10:12 gatinha96

Hmm, that's interesting. I'd recommend turning on verbose logging (FSharp.verboseLogging) and see if we're reprocessing anything. If I had to guess, it generates some msbuild/sln reload constantly.

Image

Additionally, since we do use Server GC, it's usually pretty greedy and F# compiler has lots of Large Object Heap allocations. I'd recommend enabling FSharp.fsac.gc.conserveMemory which lets dotnet collection LOH. I personally use 9 but even 1 is effective.

Image

TheAngryByrd avatar Dec 04 '25 02:12 TheAngryByrd

@TheAngryByrd I've enabled the verbose logging, here it is:

F#.log

I have also changed the conserve memory setting to 9 as you suggested, the problem still persists however.

As a side note, i can now confirm this problem is only related to Ionide F#, not the C# extension. (More details on the last message i sent on the C# Git)

gatinha96 avatar Dec 04 '25 12:12 gatinha96

The other option is to turn off Server GC and see if it's still an issue. FSharp.fsac.gc.server. The other option to try is FSharp.fsac.gc.useDatas as that tries to blend server/workstation gc modes more dynamically.

There's unfortunately nothing that points to problems in that log. You'll have to use something like dotnet dump to see what's using up memory.

TheAngryByrd avatar Dec 04 '25 14:12 TheAngryByrd

@TheAngryByrd Both options seem to make no change. Unfortunately, I'm on a company PC and it's a bit of a hassle to get permission to install new stuff, which i can't really do now :( Are you able to replicate the problem? Or is it just happening to me?

gatinha96 avatar Dec 04 '25 15:12 gatinha96

I don't have this problem with my current work project, which is a mixed C#/F# spanning 60+ projects and with 200k+ lines of F#.

Projects can be impossibly complex. Unfortunately, unless you have a project that can be shared, it's unlikely anyone can reproduce it.

TheAngryByrd avatar Dec 04 '25 17:12 TheAngryByrd

@TheAngryByrd Seems like a dead end, I'll explain what i can of my set up, hopefully it can be replicated. My project is currently a C# Unity (version 6000.2.7f2) project, i don't use F# at all (so i can disable the extension without problem).

I had it because it comes included in the .net Extension Pack, which comes with Ionide F#, C#, Polyglot Notebooks and Jupyter (Jupyter, Jupyter Cell Tags, Jupyter Keymap, Jupiter Slide Show), and their dependencies (.net install tool). Additionally, Unity, which depends on C# Dev Kit; Unity Code Snippets; ShaderLabVSCode(Free); Omni Shader Tools For Unity; Live Server; Jupyter Notebook Renderers; Git Graph V3; CMake and CMake Tools;

gatinha96 avatar Dec 05 '25 11:12 gatinha96