Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIXEL buffer leaks with "reset" #595

Closed
saitoha opened this issue Sep 26, 2016 · 2 comments
Closed

SIXEL buffer leaks with "reset" #595

saitoha opened this issue Sep 26, 2016 · 2 comments

Comments

@saitoha
Copy link
Contributor

saitoha commented Sep 26, 2016

Forwarded from saitoha/libsixel#50 (comment).

Actually, there is a memory leak already in release 2.6.1. If I output a Sixel image and clear the >scrollback buffer repeatedly (reset), it uses some memory more every time.
Maybe this should be continued in a mintty or mintty-sixel issue rather than here...

I confirmed there are two problems:

  • term.imgs.parser_state leaks in term_reset() with hard reset(RIS).
  • winimgs_clear() is not called when IDM_RESET(Alt+F8) is dispatched.

patch:

diff --git a/src/winimg.c b/src/winimg.c
index a1a9b71..19e1e23 100644
--- a/src/winimg.c
+++ b/src/winimg.c
@@ -11,6 +11,7 @@
 #include "winpriv.h"
 #include "termpriv.h"
 #include "winimg.h"
+#include "sixel.h"

 // tempfile_t manipulation

@@ -284,6 +285,11 @@ winimgs_clear(void)
 {
   imglist *img, *prev;

+  // clear parser state
+  sixel_parser_deinit(term.imgs.parser_state);
+  free(term.imgs.parser_state);
+  term.imgs.parser_state = NULL;
+
   // clear images in current screen
   for (img = term.imgs.first; img; ) {
     prev = img;
diff --git a/src/winmain.c b/src/winmain.c
index e808a2e..628d306 100644
--- a/src/winmain.c
+++ b/src/winmain.c
@@ -12,6 +12,7 @@

 #include "winpriv.h"
 #include "winsearch.h"
+#include "winimg.h"

 #include "term.h"
 #include "appinfo.h"
@@ -1268,7 +1269,7 @@ static struct {
         when IDM_COPY: term_copy();
         when IDM_PASTE: win_paste();
         when IDM_SELALL: term_select_all(); win_update();
-        when IDM_RESET: term_reset(); win_update();
+        when IDM_RESET: winimgs_clear(); term_reset(); win_update();
         when IDM_DEFSIZE:
           default_size();
         when IDM_DEFSIZE_ZOOM:
@saitoha
Copy link
Contributor Author

saitoha commented Sep 27, 2016

Thanks!

@saitoha saitoha closed this as completed Sep 27, 2016
@mintty
Copy link
Owner

mintty commented Oct 7, 2016

Released 2.6.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants