Skip to content

CPU and Memory usage balloons on home directory #1390

Description

@Teles-sd

Code editor

vim 9.2.0735-1

Platform

Arch Linux x86_64. Kernel: Linux 7.1.3-arch1-3

Version

bash-language-server version: 5.6.0. Client: vim plugin yegappan/lsp (no version tag, using most recent commit as of 24/jul/26)

What steps will reproduce the bug?

I have a language client set up with the vim plugin yegappan/lsp, with the following configuration (copied only what I thought was relevant for this):

~/.vimrc

let lspOpts = #{
            \   autoHighlightDiags: v:true,
            \   showDiagOnStatusLine: v:true,
            \   showDiagWithSign: v:true,
            \   showDiagWithVirtualText: v:true,
            \   diagVirtualTextAlign: 'after',
            \ }
autocmd User LspSetup call LspOptionsSet(lspOpts)
let lspServers = [
            \       #{name: 'bashls',
            \           filetype: 'sh',
            \           path: 'bash-language-server',
            \           args: ['start'],
            \       },
            \    ]
autocmd User LspSetup call LspAddServer(lspServers)

Then, open a sh file at home directory. That's it.

How often does it reproduce? Is there a required condition?

Consistently. In all these cases:

  • Open any sh type files at home (e.g. with vim .bashrc);
  • or files in other directories, but read from home (e.g. with vim ~/Project/whatever/somefile.sh);
  • or even files at home, but read from other directories (e.g. with cd ~/Projects && vim ../.bashrc).

What is the expected behavior?

When reading some file in, and from, another directory, it behaves ok (e.g. with cd ~/Projects/whatever/ && vim somefile.sh).

For comparison, doing as such on a directory and opening one, or a bunch, of sh files on vim will have the server memory usage fluctuate around 113M.

What do you see instead?

CPU usage for whatever core is running the server goes to 100% (ish) and Memory usage keeps going up until it starts to lag everything.

Here's a screenshot of btop for one such process:

screenshot of btop showing language server (node) process

On this case, the only file open is ~/.bashrc (which sources no file, other than my ~/.bash_aliases, if that's of any relevance), and within a minute the server is already using almost a GB. And it won't stop growing.

Additional information

I saw some issues (#1375, #912, #736) about it, and I thought shellcheck was to blame.

I then tried to set some configurations (from the config.ts file) to remedy it and verify if it really was it:

~/.vimrc

let lspServers = [
            \       #{name: 'bashls',
            \           filetype: 'sh',
            \           path: 'bash-language-server',
            \           args: ['start'],
            \           initializationOptions: #{
            \               backgroundAnalysisMaxFiles: 5,
            \               includeAllWorkspaceSymbols: v:false,
            \               shellcheckExternalSources: v:false,
            \           },
            \       },
            \    ]
autocmd User LspSetup call LspAddServer(lspServers)

But since nothing changed I wasn't sure if I was setting the configurations right on the language client and if the server was receiving them.
So I straight up uninstalled shellcheck (and also rebooted, for good measure). Aaand just to be sure:

$ type shellcheck
bash: type: shellcheck: not found
$ pacman -Qo shellcheck
error: No package owns shellcheck

And nothing changed; problem continued. So I guess it's not shellcheck's fault this time.

Other (maybe) related issues:

Not sure where to look for the output from the language server logs, but I might edit/comment this issue later with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions