-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: high memory consumption #54268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That gopls uses a lot of memory is a known (and difficult) problem. See for example #47855. However, 5gb is a lot, and we should check whether that makes sense based on your usage. Can you tell me:
Unfortunately, at the moment 5gb is not unheard-of memory usage when working on large projects, such as Kubernetes. We're working on this, but it is a long-term project. |
Unfortunately, I don't have a great way to answer the first question. The number is hard to know because of the libraries being referenced, but the project itself has 3500 Go files, though not all referenced in all parts of the code. One thing I can say is that we have a single file generated by gqlgen that has 256k lines in it and is probably a big culprit. Initially loading the project causes the machine to spin for a good five minutes or so and it'll spike to 3-4 GB pretty easily. It'll settle around 2-3 after a while but spikes as the files are edited. Multiple files could be changed at the same time with multiple vim windows going on. I do have the gopls server running for quite a long time though. |
Thanks. I expect you'll see it stay in the the ~3gb range after gopls@v0.9.2 is released. I'll take a look at the heap dump you've provided to see if I can understand this better. |
Putting this in the next milestone for additional triage. |
Not much has changed with this release. gopls remains a memory hog. gopls v0.9.4, go.mod for the project and the diagnostics file attached if anyone cares. |
I don't ever hit 1 GB of RAM (cause I'm not analyzing Maybe a short term solution for the large projects is to have a mode that only analyzes specific files (i.e opened) or some way to exclude them (directory, whatever makes sense, etc). Update: I hit 2GB on a 1500 line file. |
Closing this as resolved. Please open a new issue if you are still encountering memory issues with the v0.12.0 release (the final release is scheduled for this week). |
gopls version
go env
What did you do?
Editing Go files with vim and vim-go.
What did you expect to see?
Lower memory consumption.
What did you see instead?
Over 5GB of memory consumption; thrashing swap file.
Editor and settings
Logs
gopls.3782930-5GiB-nonames.zip
The text was updated successfully, but these errors were encountered: