Repository navigation
Language server leaks/eats 30+GB of RAM #450
Description
Activity
0.1.60.0 is an older build. The current stable release is 0.1.65.0 and should be getting downloaded by the extension. (Your extension is also last month's build, but the language server download should be independent.) I don't think we had any fixes specifically for memory usage between those releases, but you may want to try the newer build.
It would be helpful to know what project you're working on and if it's public such that we could test it. Your example in particular is interesting because it's high memory usage without the CPU usage being high.
I had this at one point too today with 0.1.65.0.
We use pipenv with the
PIPENV_VENV_IN_PROJECT=1which means that we have a .venv folder in our workspace (though also in .gitignore). No idea if that might be the cause.I've also noticed that ctrl+click on relative package references sometimes seems to spin for ever so perhaps that is causing an infinite loop that increases memory or something.
Unfortunately I can't share our code and I haven't got time at the moment to recreate it
I can confirm the memory leak too. After few hours the memory usage is huge (something about 5GB), after reload it comes back to the normal usage. But using vscode actively (but I sometimes noticed that the memory usage incresased without doing anything) slowly increases the memory usage.
Don't know if this information will be helpful but I've noticed that in the output log was printed:
Reloading modules .... done. done. done.I was wondering why the LS reloads module so many times. The upper lines were interleaved with the linting output.
I am using venv, mypy.
If I notice anything else, I will edit this comment or add a new one.
Reacted by DrakezulIt seems to me that this issue was fixed with new version of python language server (actual version 0.1.72.0, previous version 0.1.65.0).
Running vs code 2 days straight and the memory usage didn't exceed 600MB of RAM.It still needs further testing, but I just wanted to give this feedback, as I was happy seeing this issue (probably) gone in my case! Thank you very much!
While I do not know how to reproduce it I just peaked at 12GB again.
I have the 0.1.72 Version of the language server and python extension "2018.12.1"The "Process Explorer" in VS Code only showed a memory usage of ~ 3.8GB for the language server, as compared to Windows 10 Task Manager that showed ~12GB
Unfortunately the leaks are still here. But still dont know how to reproduce it.
Reacted by Mark Adamson, Lixin Liu and michaeldeltouhidulshawan commented
on Dec 31, 2018 More actionsI am using the latest version of languageServer 0.1.73. This python language server eats all my ram. For that, I can`t use vs code. Please tell me how to fix it
Reacted by Jan Stratilsame... .vscode/extensions/ms-python.python 2018.12.1/languageServer.0.1.72/Microsoft.Python.LanguageServer
eat too much RAM, i just open two simple python file..
Reacted by Carlos Llamacho, Moshiko Lev, Tomé Silva and Jan StratilGot the same thing, 25+ GB after a couple of days, not even using VS Code, just leaving it open.
Reacted by Jan StratilStrange thing is, that the python language server causes those memory leaks even if I haven't opened any .py file. It took 75% memory of my 16GB total memory.
When the language server starts, it begins analyzing every file within the workspace, which means that there won't be any difference between opening a file and not opening a file.
Without an example codebase, this is very hard to pin down. If you're also seeing CPU usage during that time, then it may be the case that the analysis isn't stopping, continuing to use more memory as it grows type information (which is #495 and #479).
Know that like #495 and #479, the memory usage issues should be handled with our new analysis approach. See Mikhail's comment here for more info: #479 (comment)
The analysis approach as a whole will be different, and the files you open will impact what gets analyzed (versus analyzing unopened files that may not be referenced).
- Reacted by Jan Stratil, HognGa4z, Janosh Riebesell and Seyyed Hossein Hasanpour
MikhailArkhipov commented
on Feb 6, 2019 More actionsI still observe regular memory leaks with current development build (2019.2.5135-alpha, Microsoft Python Language Server version 0.1.78.0). Is it supposed to be fixed in this version, Mikhail Arkhipov (@MikhailArkhipov) ?
No, it is not. That's the release branch. Our master contains an updated analyzer/language server but is not yet released for any users. When we make it generally available, we'll probably be bumping the version to v0.2.x.
Thanks a lot for your prompt answer and all your effort! Will be waiting for the 0.2.x release.
I have the same issue, leaking many GBs of memory per hour that VS Code is open. Looking forward to testing the 0.2.x release!
I have the same issue cause I need restart vs frequently.
Waiting for 0.2.x to resolve it.0.2.16 is now available on beta channel. You can set this in your VS Code
settings.jsonto get it:"python.analysis.downloadChannel": "beta"Language Server version < 0.2.16 still has the memory leak for me. Installing version 0.2.16 following Jake Bailey (@jakebailey) comment throws an error:
[Info - 1:05:59 PM] Microsoft Python Language Server version 0.2.16.0 [Info - 1:05:59 PM] Initializing for /home/user/dev/virtualenv/pytorch/bin/python [Error - 1:11:34 PM] Request textDocument/completion failed. Message: Specified argument was out of the range of valid values. Parameter name: index Code: -32000 at System.Char.IsLetter(String s, Int32 index) at Microsoft.Python.LanguageServer.Completion.CompletionItemSource.CreateCompletionItem(String text, CompletionItemKind kind) at System.Linq.Enumerable.SelectEnumerableIterator`2.ToArray() at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at Microsoft.Python.LanguageServer.Completion.ImportCompletion.TryGetCompletions(ImportStatement import, CompletionContext context) at Microsoft.Python.LanguageServer.Completion.CompletionSource.GetCompletions(IDocumentAnalysis analysis, SourceLocation location) at Microsoft.Python.LanguageServer.Implementation.Server.Completion(CompletionParams params, CancellationToken cancellationToken) at Microsoft.Python.LanguageServer.Implementation.LanguageServer.Completion(JToken token, CancellationToken cancellationToken)0.2.16 is now available on beta channel. You can set this in your VS Code
settings.jsonto get it:"python.analysis.downloadChannel": "beta"Thanks a lot for letting us know.
The beta version solved the problem.
ThanksToday I faced this issue! it took more than 10GB+ of my system RAM.
I cant reproduce it now(see below), it seems when this happens, the intellisense also stops working. and analysis goes on forever!
I'm using the latest versionPython Language Server:
Microsoft Python Language Server version 0.3.46.0
Python Extension :
2019.8.29288 (6 August 2019)
VSCode infoVersion: 1.37.0 (user setup) Commit: 036a6b1d3ac84e5ca96a17a44e63a87971f8fcc8 Date: 2019-08-08T02:33:50.993Z Electron: 4.2.7 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Windows_NT x64 10.0.17763UPDATE:
OK this happened again and I could save the log and record it before the vscode crashed!
Here is the console log :

Seyyed Hossein Hasanpour (@Coderx7) Please open a new issue; this one is old and unrelated. Providing the code that causes the issue (what you have in that file) would be helpful.
Those logs are for VS Code, not the language server, and can't help us. Check this section of our troubleshooting guide for how to enable more logging for the language server and the info we'd be interested in: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#filing-an-issue
Jake Bailey (@jakebailey) : Thanks for the heads up. I created a new issue here and provided the logs you suggested in addition to the test script I used to replicate this.

I'm not installing/updating any new packages. It just leaks lots of RAM over the time.