Closed 0xAdk closed 1 year ago
I noticed something related(?), specifically
BufNew
is triggered even when visiting existing buffers[No Name]
buffers are created whenever I switch buffersnvim +"au BufNew * echom localtime()"`
:edit .bashrc
:edit tmux.config
<c-^>
to switch back and forth between the buffers.
BufNew
handler is triggered many times, so the localtime()
result is displayed.:ls!
shows lots of [No Name]
buffers.:ls!
1 %a ".bashrc" line 198
2u - "[No Name]" line 1
3 #h "tmux.config" line 1
4u - "[No Name]" line 1
5u - "[No Name]" line 1
6u - "[No Name]" line 1
7u - "[No Name]" line 1
8u - "[No Name]" line 1
9u - "[No Name]" line 1
10u - "[No Name]" line 1
11u - "[No Name]" line 1
12u - "[No Name]" line 1
13u - "[No Name]" line 1
14u - "[No Name]" line 1
15u - "[No Name]" line 1
16u - "[No Name]" line 1
17u - "[No Name]" line 1
18u - "[No Name]" line 1
Would it be possible to provide a config with the minimum handlers enabled? Any one of them could be causing the leak.
I was able to determine a memory leak, but not in this plugin.
Min repro:
local bufnr = vim.api.nvim_create_buf(false, true)
local lines = vim.fn['repeat']({''}, 200)
for _ = 1, 100000 do
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, lines)
end
nvim --clean -u min.lua
Raised: https://github.com/neovim/neovim/pull/24134. Hopefully ASAN will blow up.
Ok, this is not strictly a memory leak. What's happening is the undo information is building. Deleting the buffer or setting undolevels=-1
frees up the memory.
Thanks for digging into that. The [No Name]
and BufNew
spam is still an issue though; I guess the use of nvim_create_buf()
means that is somewhat expected...? Is it feasible to re-use a dedicated scratch buffer instead?
I'm not able to reproduce that issue with nvim --clean
+ satellite.nvim. Are you sure it is due to this plugin?
I only get a single scratch buffer, which is what I expect since this plugin creates a scratch buffer per window.
I was pretty certain this was a memory leak at the time. Double checking with a git bisect turns out this issue was actually resolved along with #40 in e122514.
Also, I am able to recreate the unnamed buffer spam with just satellite.nvim + a mini config
vim.opt.rtp:append { vim.fn.getcwd() .. '/satellite.nvim' }
require 'satellite'.setup {}
nvim --clean -u mini_config.lua ~/.bashrc +enew
then holding <c-^>
Many thanks, I could repro that. The thing needed was a buffer small enough to not display the window. Each time <c-^>
was pressed the scrollbar was created for .bashrc
and deleted for [No Name]
. The problem was I had the scrollbar buffer's bufhidden=delete
. Changing to wipe
stops the spam, though it doesn't stop buffers from being deleted+created.
Not really sure if the incrementing buffer number is a problem or worth fixing.
The thing needed was a buffer small enough to not display the window.
Ah yes, the [No Name]
and BufNew
spam only happen if the satellite scrollbar actually appears. If the buffer contents fit in the window, then <c-^>
doesn't create a scrollbar thus doesn't create a new buffer.
Not really sure if the incrementing buffer number is a problem or worth fixing.
Visiting a buffer should not trigger BufNew
. But satellite may be blocked by Nvim limitations?
Visiting a buffer should not trigger BufNew. But satellite may be blocked by Nvim limitations?
I've blocked this autocmd via 'eventignore'
.
Describe the bug Every time I switch windows a little bit of memory is added to the neovim process.
Eventually causing stutters when switching windows and neovim taking up 5 GB+ of memory
To Reproduce
To Reproduce With mini_config.lua
mini_config.lua
```lua local plug_dir = vim.env.HOME .. '/.local/share/nvim/site/pack/packer/start' vim.opt.rtp:append { plug_dir .. '/satellite.nvim', } require 'satellite'.setup {} vim.keymap.set('n', 't', 'nvim --clean -u mini_config.lua
t
for a bitExpected behavior When switching windows neovim's memory doesn't permanently increase