To: vim_dev@googlegroups.com Subject: Patch 9.0.0770 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0770 Problem: Quickfix commands may keep memory allocated. Solution: Free memory when it's a bit much. (Yegappan Lakshmanan, closes #11379) Files: src/quickfix.c *** ../vim-9.0.0769/src/quickfix.c 2022-10-14 13:11:10.128828896 +0100 --- src/quickfix.c 2022-10-16 11:28:07.852823289 +0100 *************** *** 236,248 **** ga_init2(&qfga, 1, 256); } ! // Retain ga_data from previous use. Reset the length to zero. qfga.ga_len = 0; return &qfga; } /* * Maximum number of bytes allowed per line while reading a errorfile. */ #define LINE_MAXLEN 4096 --- 236,264 ---- ga_init2(&qfga, 1, 256); } ! // Reset the length to zero. Retain ga_data from previous use to avoid ! // many alloc/free calls. qfga.ga_len = 0; return &qfga; } /* + * The "qfga" grow array buffer is reused across multiple quickfix commands as + * a temporary buffer to reduce the number of alloc/free calls. But if the + * buffer size is large, then to avoid holding on to that memory, clear the + * grow array. Otherwise just reset the grow array length. + */ + static void + qfga_clear(void) + { + if (qfga.ga_maxlen > 1000) + ga_clear(&qfga); + else + qfga.ga_len = 0; + } + + /* * Maximum number of bytes allowed per line while reading a errorfile. */ #define LINE_MAXLEN 4096 *************** *** 3335,3340 **** --- 3351,3358 ---- msg_scroll = FALSE; msg_attr_keep((char *)gap->ga_data, 0, TRUE); msg_scroll = i; + + qfga_clear(); } /* *************** *** 3744,3749 **** --- 3762,3768 ---- ui_breakcheck(); } + qfga_clear(); } /* *************** *** 4820,4825 **** --- 4839,4846 ---- if (old_last == NULL) // Delete the empty line which is now at the end (void)ml_delete(lnum + 1); + + qfga_clear(); } // correct cursor position *** ../vim-9.0.0769/src/version.c 2022-10-15 22:06:02.734483275 +0100 --- src/version.c 2022-10-16 11:26:51.328855684 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 770, /**/ -- Q: Why does /dev/null accept only integers? A: You can't sink a float. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///