Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Language server leaks/eats 30+GB of RAM #450

Closed
Ark-kun opened this issue Dec 3, 2018 · 25 comments
Closed

Language server leaks/eats 30+GB of RAM #450

Ark-kun opened this issue Dec 3, 2018 · 25 comments
Assignees

Comments

@Ark-kun
Copy link

Ark-kun commented Dec 3, 2018

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

 PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                                                                                                                             
139520 avolkov   20   0   30.8g  24.1g   1452 S   1.0  38.4 254:31.27 /home/avolkov/.vscode/extensions/ms-python.python-2018.10.1/languageServer.0.1.60/Microsoft.Python.LanguageServer                                                                                  
203203 avolkov   20   0   17.6g   9.4g   1540 S   1.0  14.9  99:36.68 /avolkov/.vscode/extensions/ms-python.python-2018.10.1/languageServer.0.1.60/Microsoft.Python.LanguageServer 
@jakebailey
Copy link
Member

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.

@mungojam
Copy link

mungojam commented Dec 4, 2018

I had this at one point too today with 0.1.65.0.

We use pipenv with the PIPENV_VENV_IN_PROJECT=1 which 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

@MikhailArkhipov MikhailArkhipov self-assigned this Dec 5, 2018
@gramster gramster added the GA label Dec 5, 2018
@Honzys
Copy link

Honzys commented Dec 10, 2018

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.

@Honzys
Copy link

Honzys commented Dec 15, 2018

It 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!

@Drakezul
Copy link

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

@Honzys
Copy link

Honzys commented Dec 23, 2018

Unfortunately the leaks are still here. But still dont know how to reproduce it.

@touhidulshawan
Copy link

I 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

@chopin1998
Copy link

same... .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..

@koliyo
Copy link

koliyo commented Jan 11, 2019

Got the same thing, 25+ GB after a couple of days, not even using VS Code, just leaving it open.

@Honzys
Copy link

Honzys commented Jan 16, 2019

Strange 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.

@jakebailey
Copy link
Member

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).

@Penagwin
Copy link

Uhhh... Explains why everything was slower then normal I guess... Best part is that after a certain point intellisense stops working in python altogether.
microsoftteams-image 1

Microsoft Python Language Server version 0.1.75.0
Python Extension 2018.12.1
VSCode 1.30.2
Mac OSX High Sierra 10.13.6

@MikhailArkhipov
Copy link

#546

@coobas
Copy link

coobas commented Feb 12, 2019

I 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, @MikhailArkhipov ?

@jakebailey
Copy link
Member

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.

@coobas
Copy link

coobas commented Feb 12, 2019

Thanks a lot for your prompt answer and all your effort! Will be waiting for the 0.2.x release.

@koliyo
Copy link

koliyo commented Feb 20, 2019

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!

@lunxian
Copy link

lunxian commented Mar 3, 2019

I have the same issue cause I need restart vs frequently.
Waiting for 0.2.x to resolve it.

@jakebailey
Copy link
Member

0.2.16 is now available on beta channel. You can set this in your VS Code settings.json to get it:

"python.analysis.downloadChannel": "beta"

@tomrunia
Copy link

tomrunia commented Mar 7, 2019

Language Server version < 0.2.16 still has the memory leak for me. Installing version 0.2.16 following @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)

@coobas
Copy link

coobas commented Mar 8, 2019

0.2.16 is now available on beta channel. You can set this in your VS Code settings.json to get it:

"python.analysis.downloadChannel": "beta"

Thanks a lot for letting us know.

@dreamfalcon
Copy link

The beta version solved the problem.
Thanks

@Coderx7
Copy link

Coderx7 commented Aug 12, 2019

Today 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 version

Python Language Server:
Microsoft Python Language Server version 0.3.46.0
Python Extension :
2019.8.29288 (6 August 2019)
VSCode info

Version: 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.17763

UPDATE:

OK this happened again and I could save the log and record it before the vscode crashed!
Here is the console log :
languagesever_ipython_vscode3

@jakebailey
Copy link
Member

@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

@Coderx7
Copy link

Coderx7 commented Aug 12, 2019

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests