goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.78k stars 104 forks source link

bug: Calling AlphaRedraw causes more memory to be allocated on each call #189

Closed PriceHiller closed 1 year ago

PriceHiller commented 1 year ago

I am attempting to make a simple component that updates every second to display time. So a clock.

I created a loop that calls AlphaRedraw and after playing around with it I noticed that this causes a massive memory allocation on every call that doesn't erase previous memory. This leads to what I assume to be a memory leak eventually crashing my system due to an out of memory error.

I wasn't able to find any documentation noting how to use AlphaRedraw, so if this is intended to not be touched then perhaps a user command shouldn't be registered.

My Alpha config can be found here with the loop I'm mentioning at the bottom of that file.

Video and a few notes:

  1. I have disabled the loop and am manually calling AlphaRedraw to show the memory increase
  2. Notice that the memory only increases significantly (after I let it "settle") on each AlphaRedraw call
  3. I am using htop to display the memory usage on the right split
  4. At the end I wait and do nothing for a while to show that Neovim isn't increasing in memory usage if I don't call AlphaRedraw

https://user-images.githubusercontent.com/58627896/223439242-bbf0e86b-f407-403a-9651-4e313078e716.mp4

goolord commented 1 year ago

fixed here https://github.com/goolord/alpha-nvim/commit/471d15ff3983d9ea4bf0333405f74a46d0bfb22e

highlights compose and thus every frame's highlights were kept in memory, so we just clear highlights for the alpha buffer before drawing

PriceHiller commented 1 year ago

Thanks for the quick turnaround, can confirm on my side that it's been fixed.