jarun/nnn

Preview-tui and kitty: previewing large gif file ( >7 mb) doesn't free ram upon closing nnn or preview-tui plugin

izmyname opened this issue · 3 comments

  • Operating System: Arch Linux
  • Desktop Environment: i3
  • Terminal Emulator: kitty
  • Shell: zsh
  • Custom desktop opener (if applicable): none
  • Program options used: exP -p(preview-tui)
  • [ ] Configuration options set:
  • Plugins are installed: 'm:mtpmount;p:preview tui;f:fzopen;M:nmount;s:suedit;u:getplugs;g:gpge;G:gpgd;i:-!|mediainfo "$nnn";l:-!less -iR "$nnn"*;x:!&gio launch "$nnn"'
  • [ ] Issue exists on nnn master: unsure, but plugins are the latest version.

Exact steps to reproduce the issue

I. Launch nnn and preview-tui plugin

II. Focus on a large gif file (>7mb). It will cause increased ram usage, the gif will be displayed with approximately 5 seconds delay.

III. Close preview-tui and nnn. Increased ram usage remains as if the gif were still rendering.

There aren't any the gif-related files in /tmp, opening the gif directly from terminal with icat kitten, then closing the terminal reduces ram usage back.

UPD: It looks like the RAM is freed if all the gif's frames are rendered, but closing preview-tui or nnn, prior that, causes the problem and semi-rendered gif remains somewhere in RAM causing increased usage.

Is this really an issue with preview-tui? I can reproduce the problem with kitty but it seems to me that it should be up to kitty or the icat kitten to release the memory.

Problem is not present with ueberzug which uses an insignificant amount of memory in the first place. I see memory usage increase with 500MB each time I open and close preview-tui in kitty on a large gif, lol.

I can reproduce simply with:

wget https://upload.wikimedia.org/wikipedia/commons/0/0b/New_cyclic_large.gif
kitty +kitten icat --transfer-mode=stream New_cyclic_large.gif

Repeatedly executing icat in --transfer-mode=stream and pressing Ctrl-C to exit results in ever increasing memory usage. The memory is never freed even after closing the terminal.

I would suggest to open an issue over on the kitty repo, though it seems the previous one was shot down: kovidgoyal/kitty#6627.