baskerville / bspwm

A tiling window manager based on binary space partitioning
BSD 2-Clause "Simplified" License
7.73k stars 414 forks source link

Memory leak when openning many tabs #1422

Open RegreTTO opened 1 year ago

RegreTTO commented 1 year ago

Experiment

  1. Measure memory usage after boot (in my case it is ~800M)
  2. Hold win+Enter for a while
  3. Obviously, your memory usage will grow (in my case it becomes ~5000M)
  4. Then kill all opened terminal windows
  5. Get memory usage larger then at the start (in my case 1800)

    Question

    How to fix it?

zjeffer commented 1 year ago

I can't reproduce this with gnome-terminal. Which terminal are you using to test this? Does it happen with other windows?

RegreTTO commented 1 year ago

I use alacritty terminal. And yes, it happens in all windows

camarman commented 1 year ago

I am using Fedora 36 with GNOME and in this config, I set up bspwm with polybar.

I did the same experiment as you did (by using alacritty) but I also did not produce any memory leak.

My default memory was about 1324Mib then it jumped to 3000Mib. Later on, I closed the windows one by one and it reduced to 1313Mib.

3. Then kill all opened terminal windows

Did you killed all at once or one by one ? Maybe that could be the difference...? if not then maybe it's not about bspwm but something else causing the problem.

RegreTTO commented 1 year ago

I killed them by holding my "kill node" hotkey (in my case win+x). I assumed that the problem is not in bspwm, so i checked my .zshrc for broken strings. Unfortunately, I hadn't found any of suspicious code there. Because of this, I thought of bspwm. How do you think, may the problem be in my picom config or somewhere else?

RegreTTO commented 1 year ago

Also, i've tried to measure memory usage by htop, but it is very strange that it doesnt show all of memory consumers. For examle, when I was fixing my picom (by the way it was about memory consumption too) I tried to analyze memory usage in htop too, but it was showing that everything was ok. The problem was in the fact that picom was rerendering window again and again, so my memory said goodbye. It makes me mad sometimes when htop hides some essential information from me

zjeffer commented 1 year ago

Try reproducing this with a minimal amount of external factors: for example when picom & polybar are not running.

Which processes are actually using more memory?

RegreTTO commented 1 year ago

I've rebooted my laptop, killed picom and polybar and done the same. As a result my memory usage raised form 600M to 1000M and won't drop down. Here is my htop view изображение

RegreTTO commented 1 year ago

It seems to be in alacritty, but after killall alacritty nothing changes

zjeffer commented 1 year ago

I notice you're using 'copyq'. I found this on their GitHub issues: https://github.com/hluk/CopyQ/issues/1928. Could this be the problem?

When you killall alacrity and 'nothing happens', do you mean they don't get killed or that the RAM usage doesn't drop? Try seeing what happens when killing from another terminal. See which programs are using the most ram after killing alacritty.

RegreTTO commented 1 year ago

Thanks for the CopyQ issue. I'll definetely read this. After killing all alacritty I mean that they actually killed and RAM usage dropped, but it is still higher than after boot. How can I see which programs are using the most ram after killing alacritty by not using htop, because when I launch htop even though launch menu alacritty starts and eats the most of memory? By the way my htop screen from previous comment was done in exactly same way as I've described

zjeffer commented 1 year ago

Simply don't use alacrity to run htop :) Launch another terminal and then execute htop there.

RegreTTO commented 1 year ago

makes sense)

RegreTTO commented 1 year ago

So, I've done the same things as were described in my first comment and run htop through xterm. Here is screenshot (it's pretty awful because I don't use xterm usually) By the way, copyq is not a reason. I killed it but my memory usage wasn't changed изображение

RegreTTO commented 1 year ago

ok, I've tried to open about 200 xterms and after killing them my memory returned... May the problem be in alacritty in this way?

bitterhalt commented 1 year ago

I stopped using Alacritty because of these memory leaks. I think that this is not BSPWM problem at all.

RegreTTO commented 1 year ago

By the way, what are good alternatives for alacritty?

bitterhalt commented 1 year ago

By the way, what are good alternatives for alacritty?

If you must have something with GPU acceleration then Kitty is great although It is also very RAM hungry.

wuhanhui commented 1 year ago

I meeting the same problem but with the chrome. If I make the chrome floating. And resize the chrome then the memory is increasing.