-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/gopls: uses too much memory (60G) #37790
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
Thanks for the report. There should be some files named gopls.PID- in your temporary directory, named after heap sizes. Please upload the pair for the largest heap -- I would like to see a goroutine dump that matches this heap dump. |
Thanks again. I don't see any signs of a bug here but this is a massive heap. Are you using |
I'm working with TiDB codebase. |
Same here. I had to uninstall the gopls as my system went for a toss. I had to hard reboot my system. |
@paulsubrata55 I'm sorry you're having trouble, but without a profile or a repro there is absolutely nothing anyone can do to help you. Please follow the instructions above. |
@bobotu I believe some changes I landed today have improved memory usage on large projects substantially. Could you try |
@heschik opening TiDB at the root directory will eat up all my 8 GB memory(finally killed by OOM). It is a little better if you just use gopls in a very small directory(< 1 GB memory footprint). I think gopls needs to be more "lazy" about the imported package(at least provide an option to avoid pulling all dependencies)... |
@xhebox I'm sorry you're having trouble, but I cannot reproduce the problem. Please follow the instructions above to collect memory usage information. |
@heschik This is the memory profile: at github.com/pingcap/tidb/kv directory, open memdb_buffer.go file, with
Yes, you are right that maybe there is no bug. But I believe that gopls may have parsed all files under kv directory. Because memdb_buffer.go only imports tidb/kv/memdb(which costs about 100-150MB alloc), three standard libraries, and pingcap/errors. I expect it is about 200MB alloc, but it turns to be 600-700MB alloc. I would like to let gopls only parse this opening file, lazily load type info(e.g. gopls only loads the info of |
I couldn't agree more. No one needs info of all packages all the time. Instead, memory resource are more valuable. |
this is my go.mod file, after a few gd jump, it consume 4-5G memory, it hurt my build speed badly :
|
The original issue reporter is no longer responding and I believe this issue is resolved or at least improved, so I'm closing the issue. gopls is currently expected to use ~1GiB on a project of any significant size. Memory usage below that is unfortunately not a bug. We need to load a lot of information about each package to type check the project and to support features like Find References. As I've said multiple times on this issue, I need the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputVS Code settings
What did you do?
After about half an hour, the gopls eat all of my RAM.
What did you expect to see?
Not use too many memory
What did you see instead?
atop
says it has used nearly all RAM on my machine.heap profile
The text was updated successfully, but these errors were encountered: