natebosch / vim-lsc

A vim plugin for communicating with a language server
BSD 3-Clause "New" or "Revised" License
693 stars 83 forks source link

VIM Memory Leak #243

Open photon3108 opened 4 years ago

photon3108 commented 4 years ago

My vim process uses about 700MB resistant memory and makes GoToDefinition(ctrl+]) slower each time. I tried to figure out what happened but I'm not familiar with vim debug tools and vim scripts. I reassigned empty string to the buffer and it shows its length 0. But it doesn't work. I'm not sure if it holds the 700MB array under the implementation or not. prabirshrestha/vim-lsp doesn't have this problem in this kind of server-client async design. It means the memory leak could be resolved in this design. But it doesn't integrate dart very well.

The reproducing steps are

  1. flutter create a default project.
  2. vim lib/main.dart.
  3. Use top to monitor memory at another terminal tab.
  4. vim uses about 20MB.
  5. vim goes into MaterialApp in main.dart by GoToDefinition(ctrl+]).
  6. CPU usage goes high.
  7. Waits 10 seconds.
  8. vim uses about 700MB and it is never released.

OS: Ubuntu 16.04 VIM: 8.1 1-2292 VIM Plugin: 'dart-lang/dart-vim-plugin' 'natebosch/vim-lsc' 'natebosch/vim-lsc-dart' let g:lsc_server_commands = {'dart': 'dart_language_server'} let g:lsc_reference_highlights = v:false

natebosch commented 4 years ago

I'm not able to repro. My memory usage stays reasonably low when I jump to definition on MaterialApp. One difference I suspect might be in play is that I've done some local development in my checkout of flutter.

My initial hunch is that what you are seeing is a huge number of false analyzer diagnostics come back for the files in the flutter package.

When you get into this state could you try running :LSClientAllDiagnostics and see if anything shows up? In my test nothing shows up, because all of the flutter package is analyzable without errors, and sow is the default app from flutter create.

If you get a bunch of stuff showing up here then we'll know the root cause and I can start thinking about a fix.