atanunq / viu

Terminal image viewer with native support for iTerm and Kitty
MIT License
2.57k stars 58 forks source link

Redirection or piping of output causes a memory leak #75

Closed tooeffayy closed 3 years ago

tooeffayy commented 3 years ago

Running on Arch Linux using Kitty. If I try to do viu image.jpg | less -R or even viu image.jpg > testfile then it will max out a single thread and fill memory until OOM killer stops it. Redirection works fine in half block mode using tmux or alacritty. I have tried both the Arch package and installing from source.

~/.cargo/bin ➜ ./viu ~/Pictures/001.jpg | less -R
[1]    52301 killed     ./viu ~/Pictures/001.jpg | 
       52302 done       less -R
atanunq commented 3 years ago

Thank you for reporting! I found out the root cause - when viuer tries to check the level of Kitty support in the terminal, it sends a request and waits for a response. Unfortunately, when not in a tty, the underlying library just returns key::Unknown over and over again, filling up an unbounded vector.

Still, not running in a tty results in some weird, unintended interactions... Please let me know if you have some ideas on how viu should behave in such conditions