lewis6991 / satellite.nvim

Decorate scrollbar for Neovim
MIT License
542 stars 20 forks source link

Memory leak on scroll #40

Closed nenikitov closed 1 year ago

nenikitov commented 1 year ago

Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. Load a file large enough to be scrolled
  2. Note the memory usage
  3. Start scrolling
    • Easy to reproduce when scrolling up and down with mouse wheel
    • Also applies when scrolling with j and k, but will be slower
  4. Note that the memory and CPU usage quickly increase
  5. Stop scrolling
  6. Notice that memory usage didn't go down

Expected behavior

Screenshots Note tested with a file with 64 lines. Scrolled up and down with mouse wheel. Note the MemB of the 2nd process.

Additional context

lewis6991 commented 1 year ago

Can you figure out which handler is causing the leak?

nenikitov commented 1 year ago

Memory leak is still present after removing all handlers

return {
    "lewis6991/satellite.nvim",
    config = function()
        require("satellite").setup {
            handlers = {
                search = { enable = false },
                diagnostic = { enable = false },
                gitsigns = { enable = false },
                marks = { enable = false }
            }
        }
    end,
}

Before scrolling: image

After scrolling: image

Forgot to mention, here is the output of nvim --version (I also updated the issue)

NVIM v0.9.0-dev-873+g4b9bb3a184
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fno-common -fdiagnostics-color=always -fstack-protector-strong -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DMIN_LOG_LEVEL=3 -DNVIM_UNIBI_HAS_VAR_FROM -I/usr/include/luajit-2.1 -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/home/nenikitov/.cache/yay/neovim-git/src/build/src/nvim/auto -I/home/nenikitov/.cache/yay/neovim-git/src/build/include -I/home/nenikitov/.cache/yay/neovim-git/src/build/cmake.config -I/home/nenikitov/.cache/yay/neovim-git/src/neovim/src -I/usr/include -I/usr/include -I/usr/include
Compiled by nenikitov

Features: +acl +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
lewis6991 commented 1 year ago

Thanks for the report. #41 should fix a leak. Can you check?

nenikitov commented 1 year ago

I don't think it helped with my memory leak:

image image

If it helps, running :SatelliteDisable and :SatelliteEnable resets the memory usage

lewis6991 commented 1 year ago

That's not the right commit. It needs to be 385e67fc9942b6ed87086c700c627b581ed583d4

nenikitov commented 1 year ago

Hello,

I didn't notice that the fix is on a separate branch. After updating to the right commit: image

It seems like the memory leak is fixed (here is the memory usage after scrolling): image

Thank you for the fix