Ask questionslsp-completion-no-cache not honored

Thank you for the bug report

  • [X] I am using the latest version of lsp-mode related packages.
  • [X] I checked FAQ and Troubleshooting sections
  • [] You may also try reproduce the issue using clean environment using the following command
emacs -q -l lsp-start-plain.el

where lsp-start-plain.el can be downloaded here. Alternatively, it will be great if you can reproduce the issue using lsp-docker which provides the minimal configurations for lsp-mode and ships with most of the language servers.

Bug description

Tracing a memory leak that occurred while using lsp-emacs (with Flutter projects), after Emacs reached 2.4 GB I dumped the process image and found 300000+ instances of the string _emacsStartPoint, which brought me to lsp-completion.el.

As an experiment, on a new Emacs session assigned t to lsp-completion-no-cache. After working with a Flutter project for a while, the memory leak manifested itself again. Contrary to my expectations, lsp-completion--cache contained data. Inspecting the source code I see some assignments to that variable not guarded by a check of lsp-completion-no-cache.

Steps to reproduce

Set lsp-completion-no-cache to t and do work for a while.

Expected behavior

lsp-completion--cache remains empty.

Which Language Server did you use?




Error callstack

No response

Anything else?

No response


Answer questions kiennq

The lsp-completion-no-cache here means not caching the returned completions from the server per keystroke. I.e,: we sent a new completion request on every user key typed. The lsp-completion--cache is used even in that case since on one keystroke, we may have multiple calling to completion-at-point function, also we used that as global var to pass value around to processing in one keystroke too. That's why the lsp-completion--cache may contain value even if lsp-completion-no-cache is set.

@yyoncho Do we have a method to force release memory immediately (not waiting for garbage collection) after the memory is no longer use by us?

Github User Rank List