vscode-csharp
vscode-csharp copied to clipboard
Too many open files on my solution
Issue Description
Unable to work normally with my solution because of "Too many open files". inotify watches is set to maximum:
cat /proc/sys/fs/inotify/max_user_watches
524288
In the folder I've opened lays several dotnet solutions, biggest one with 300+ projects.
Steps to Reproduce
Open folder with solution. Wait for 3-5 minutes.
Expected Behavior
VSCode able to work with big solution
Actual Behavior
VSCode unable to work with big solution
OmniSharp log
System.InvalidOperationException: object_op ---> System.IO.IOException: Too many open files
at System.IO.Enumeration.FileSystemEnumerator`1[TResult].CreateDirectoryHandle (System.String path, System.Boolean ignoreNotFound) [0x00032] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.Enumeration.FileSystemEnumerator`1[TResult]..ctor (System.String directory, System.IO.EnumerationOptions options) [0x00048] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.Enumeration.FileSystemEnumerable`1+DelegateEnumerator[TResult]..ctor (System.IO.Enumeration.FileSystemEnumerable`1[TResult] enumerable) [0x00000] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.Enumeration.FileSystemEnumerable`1[TResult]..ctor (System.String directory, System.IO.Enumeration.FileSystemEnumerable`1+FindTransform[TResult] transform, System.IO.EnumerationOptions options) [0x00042] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories (System.String directory, System.String expression, System.IO.EnumerationOptions options) [0x00014] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.Directory.InternalEnumeratePaths (System.String path, System.String searchPattern, System.IO.SearchTarget searchTarget, System.IO.EnumerationOptions options) [0x00045] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.Directory.EnumerateDirectories (System.String path, System.String searchPattern, System.IO.EnumerationOptions enumerationOptions) [0x00000] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.Directory.EnumerateDirectories (System.String path) [0x0000b] in <4f52a2659e1844fea7ab38854dcbcf68>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0016c] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.AddDirectoryWatchUnlocked (System.IO.CoreFX.FileSystemWatcher+RunningInstance+WatchedDirectory parent, System.String directoryName) [0x0018d] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher+RunningInstance..ctor (System.IO.CoreFX.FileSystemWatcher watcher, Microsoft.Win32.SafeHandles.SafeFileHandle inotifyHandle, System.String directoryPath, System.Boolean includeSubdirectories, System.IO.NotifyFilters notifyFilters, System.Threading.CancellationToken cancellationToken) [0x0005c] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher.StartRaisingEvents () [0x000dd] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher.StartRaisingEventsIfNotDisposed () [0x00019] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFX.FileSystemWatcher.set_EnableRaisingEvents (System.Boolean value) [0x0001d] in <883cd000faa842148a99b174e3bd5ca4>:0
at (wrapper remoting-invoke-with-check) System.IO.CoreFX.FileSystemWatcher.set_EnableRaisingEvents(bool)
at System.IO.CoreFXFileSystemWatcherProxy+<>c.<StartDispatching>b__9_0 (System.IO.CoreFX.FileSystemWatcher internal_fsw, System.IO.FileSystemWatcher fsw) [0x00048] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFXFileSystemWatcherProxy.Operation (System.Action`4[T1,T2,T3,T4] map_op, System.Action`2[T1,T2] object_op, System.Object handle, System.Action`2[T1,T2] cancel_op) [0x00184] in <883cd000faa842148a99b174e3bd5ca4>:0
--- End of inner exception stack trace ---
at System.IO.CoreFXFileSystemWatcherProxy.Operation (System.Action`4[T1,T2,T3,T4] map_op, System.Action`2[T1,T2] object_op, System.Object handle, System.Action`2[T1,T2] cancel_op) [0x001a6] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.CoreFXFileSystemWatcherProxy.StartDispatching (System.Object handle) [0x00004] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.FileSystemWatcher.Start () [0x0001b] in <883cd000faa842148a99b174e3bd5ca4>:0
at System.IO.FileSystemWatcher.set_EnableRaisingEvents (System.Boolean value) [0x0003d] in <883cd000faa842148a99b174e3bd5ca4>:0
at (wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher.set_EnableRaisingEvents(bool)
at Microsoft.AspNetCore.Razor.OmniSharpPlugin.MSBuildProjectDocumentChangeDetector.ProjectLoaded (OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs loadedArgs) [0x00266] in <8c6f4eb2e16d4051ba80a599aba81c54>:0
at OmniSharp.MSBuild.ProjectManager.ProcessQueue (System.Threading.CancellationToken cancellationToken) [0x00198] in <559e0651ed234d568cb45fca36d98a0c>:0
Environment information
VSCode version: 1.39.2 C# Extension: 1.21.5
Mono Information
OmniSharp using global mono :6.0.0Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 2.2.108 Commit: 33ed5b90ceRuntime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /opt/dotnet/sdk/2.2.108/
Host (useful for support): Version: 2.2.6 Commit: 7dac9b1b51
.NET Core SDKs installed: 2.2.108 [/opt/dotnet/sdk]
.NET Core runtimes installed: Microsoft.NETCore.App 2.2.6 [/opt/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions
Extension | Author | Version |
---|---|---|
csharp | ms-vscode | 1.21.5 |
dotenv | mikestead | 1.0.1 |
EditorConfig | EditorConfig | 0.14.2 |
Go | ms-vscode | 0.11.7 |
Material-theme | zhuangtongfa | 2.28.2 |
path-intellisense | christian-kohler | 1.4.2 |
plantuml | jebbs | 2.12.1 |
rainbow-csv | mechatroner | 1.3.1 |
rest-client | humao | 0.22.2 |
synthwave-vscode | RobbOwen | 0.0.7 |
terraform | mauve | 1.4.0 |
vscode-docker | ms-azuretools | 0.8.1 |
vscode-icons | vscode-icons-team | 9.5.0 |
vscode-yaml | redhat | 0.5.3 |
cc @NTaylorMullen - this is interesting, since the exception is coming from CoreFX
I'm having a very similar issue, any fix?
I am now running into this issue whenever I open VSCode and work on my project in Linux. The workaround that I found is this:
https://stackoverflow.com/questions/43469400/asp-net-core-the-configured-user-limit-128-on-the-number-of-inotify-instance
I recently discovered that when restarting vscode (usualy after a debugger crash) the plugin also crashes and remains in memory. This can be verified using ps aux | grep dotnettools
, and/or a tool that counts inotify watches.
So we need to kill those processes to release the watches. Then vscode can be started normally.
This MAJOR problem has been in existence for years. It's something I struggle with multiple times every day.
Related:
- https://github.com/OmniSharp/omnisharp-vscode/issues/5178
- https://github.com/OmniSharp/omnisharp-vscode/issues/2851
- https://github.com/OmniSharp/omnisharp-vscode/issues/5284
- https://github.com/OmniSharp/omnisharp-vscode/issues/3284
- https://github.com/OmniSharp/omnisharp-vscode/issues/3368
- https://github.com/OmniSharp/omnisharp-vscode/issues/4350
Possible diagnoses:
- https://github.com/Azure/bicep/issues/8171#issuecomment-1232322963
- https://github.com/OmniSharp/omnisharp-vscode/issues/4350#issuecomment-1163536551
The vscode team has had trouble reproducing this issue; I hope aggregating these will help them repro and find the root cause.