Skip to content
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

Memory leak when using mouse scroll #60

Closed
cehteh opened this issue Oct 16, 2024 · 6 comments
Closed

Memory leak when using mouse scroll #60

cehteh opened this issue Oct 16, 2024 · 6 comments

Comments

@cehteh
Copy link

cehteh commented Oct 16, 2024

Since quite some i have a memory leak with rustic when using the mouse wheel and scrolling down to the bottom of a rust source file.

CPU usage goes to 100% and memory usage dramatically increases until it hits OOM pretty fast.

This only happens when rustic is enabled, not in any other mode, not in rust-mode either and only when scrolling down with the mouse wheel. Not when hitting the bottom with cursor/pg-down.

I use emacs from debian-stable

$ emacs --version
GNU Emacs 29.4

and use-package/vc-use-package bleeding edge rustic:

(use-package rustic
  :vc (:fetcher github :repo emacs-rustic/rustic)
  :after (rust-mode)
  :demand t
  :init  (setq rust-mode-treesitter-derive t)
  :custom-face
  (my-rustic-self-keyword-face ((t (:inherit font-lock-keyword-face))))
  :hook
  (rustic-mode . (lambda () (font-lock-add-keywords nil '(("\\<self\\>" . 'my-rustic-self-keyword-face))))))
@psibi
Copy link
Member

psibi commented Oct 17, 2024

Thanks for the report! Is it possible to add profiling result: https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html ?

@cehteh
Copy link
Author

cehteh commented Oct 17, 2024

Ah thats getting closer

    434,170,109  77% - redisplay_internal (C function)
    297,845,620  52%  - lsp--update-inlay-hints-scroll-function
    297,845,620  52%   - lsp-update-inlay-hints
    154,020,004  27%    - lsp-request-async
    141,366,708  25%     - lsp--send-request-async
     68,159,224  12%      - lsp--find-workspaces-for
     66,239,576  11%       - -filter
     65,896,376  11%        - #<compiled 0x10372dd4a6892c93>
     64,864,664  11%         - apply
     64,864,664  11%          - lsp--workspace-method-supported?
     64,864,664  11%           - lsp--capability
     64,223,488  11%              lsp--server-capabilities
        641,176   0%              lsp-get
     53,709,196   9%      - seq-do
     53,709,196   9%       - mapc
     51,991,084   9%        - #<compiled 0x9dfd62054309ff0>
     50,608,780   8%         - lsp--send-no-wait
     50,261,356   8%          - lsp-process-send
     50,261,356   8%           - apply
     50,261,356   8%              #<compiled 0x67f24b53ed105e4>
      7,889,808   1%        #<compiled 0xad33ec27456224>
      3,359,808   0%    - lsp-make-range
      2,090,880   0%     - -partition
      2,090,880   0%      - -partition-in-steps
      1,394,976   0%         dash--partition-all-in-steps-reversed
      1,268,928   0%       #<compiled 0x1c5900af126ac0f5>
      3,357,200   0%      lsp-point-to-position
      3,324,176   0%    - lsp-make-inlay-hints-params
      2,064,480   0%     - -partition
      2,064,480   0%      - -partition-in-steps
      1,377,024   0%         dash--partition-all-in-steps-reversed
      1,259,696   0%       #<compiled 0x1c69f963360ac0f5>
    133,282,160  23%  - eval
     50,859,744   9%     if
     23,565,052   4%     mapconcat
      5,516,544   0%     flycheck-mode-line-status-text
      1,377,024   0%     unless
        630,896   0%     concat
      2,772,000   0%  + mode-line-default-help-echo
          6,641   0%  + copilot--on-doc-focus
    120,794,309  21% - #<compiled -0x11fb66ecbc42d1f4>
     42,981,363   7%    apply
     24,164,072   4%  - mapc
     24,164,072   4%   - #<compiled -0x1ea398d7491920fd>
     24,164,072   4%    - lsp--parser-on-message
     24,164,072   4%     - #<compiled 0xaec9a33a82529a5>
     13,325,688   2%      - #<compiled 0x101d4e5f0dcf501e>
     11,951,832   2%       - #<compiled 0xa39d60809212b28>
     11,951,832   2%        - apply
     11,932,994   2%         - #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_460>
     11,235,280   1%            lsp--remove-overlays
          5,200   0%            lsp--position-to-point
          3,360   0%         - lsp--document-highlight-callback
          2,304   0%            lsp--remove-overlays
          1,056   0%            -map
        344,256   0%         lsp--merge-results
     10,151,984   1%      - lsp--request-cleanup-hooks
     10,151,984   1%       - #<compiled -0x21d56753f1894b>
      3,654,192   0%        - mapc
      3,654,192   0%         - #<compiled -0x1c7be7848410fe18>
         11,616   0%            remove-hook
     10,724,096   1%  - mapcar
      9,089,536   1%     lsp--parse-header
      2,755,920   0%  - #<compiled -0x1c8e48f527b9bf7f>
      2,412,720   0%   - kill-buffer
      2,412,720   0%    - apply
      2,412,720   0%     - ad-Advice-kill-buffer
      1,027,488   0%        #<subr kill-buffer>
      7,067,325   1% + command-execute
        342,800   0% + timer-event-handler
         28,014   0% + flyspell-post-command-hook
         18,288   0% + gcmh-register-idle-gc
         12,584   0% + lsp--post-command
          9,360   0% + flycheck-display-error-at-point-soon
          7,568   0% + copilot--post-command
          1,056   0%   yas--post-command-handler
             72   0% + eldoc-schedule-timer
              0   0%   ...

@cehteh
Copy link
Author

cehteh commented Oct 17, 2024

Switching lsp-inlay-hints-mode off won't busy-loop/memory leak anymore

@psibi
Copy link
Member

psibi commented Oct 17, 2024

I was going to ask you to try that. :-) Can you open an issue in lsp-mode since this seems to be because of it ?

@cehteh
Copy link
Author

cehteh commented Oct 17, 2024

lsp-update-inlay-hints-on-scroll is the culprit! disabling that fixes my problem. .. i will forward it to lsp-mode

@cehteh
Copy link
Author

cehteh commented Oct 17, 2024

I was going to ask you to try that. :-) Can you open an issue in lsp-mode since this seems to be because of it ?
Thanks for your help!

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

No branches or pull requests

2 participants