I notice a memory leak in Vim-7.2.233 (and older) whenever I do:
:set term=builtin_dumb
If you execute above command n times, it will leak n blocks of memory.
Memory is allocated here:
==13315== 10 bytes in 2 blocks are definitely lost in loss record 127 of 162
==13315== at 0x402603E: malloc (vg_replace_malloc.c:207)
==13315== by 0x812F556: lalloc (misc2.c:866)
==13315== by 0x812F461: alloc (misc2.c:765)
==13315== by 0x812F96A: vim_strsave (misc2.c:1177)
==13315== by 0x815A459: set_string_option_direct (option.c:5353)
==13315== by 0x81CA9B1: set_color_count (term.c:1565)
==13315== by 0x81CAD91: set_termname (term.c:1740)
==13315== by 0x815A843: did_set_string_option (option.c:5497)
==13315== by 0x81593CE: do_set (option.c:4678)
==13315== by 0x80CED24: ex_set (ex_docmd.c:10983)
==13315== by 0x80C1F94: do_one_cmd (ex_docmd.c:2627)
==13315== by 0x80BF7CB: do_cmdline (ex_docmd.c:1096)
==13315== by 0x81457EA: nv_colon (normal.c:5224)
==13315== by 0x813F03E: normal_cmd (normal.c:1188)
==13315== by 0x8101DB5: main_loop (main.c:1186)
==13315== by 0x8101902: main (main.c:942)
option.c:
5353 s = vim_strsave(val);
5354 if (s != NULL)
5355 {
5356 varp = (char_u **)get_varp_scope(&(options[idx]),
5357 both ? OPT_LOCAL : opt_flags);
5358 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
5359 free_string_option(*varp);
5360 *varp = s;
Chasing with gdb, I found that the leak happens shortly later
in term.c in ttest():
2882 /* if 'Sb' and 'AB' are not defined, reset "Co" */
2883 if (*T_CSB == NUL && *T_CAB == NUL)
2884 T_CCO = empty_option; <---------------- LEAK!
Line 2884 replaces T_CCO, which had been previously dynamically
allocated in option.c:5353, by empty_option. T_CCO should be freed
before being replaced (I assume T_CCO is always dynamically allocated
if it was not empty_option).
Attached patch fixes it.
-- Dominique
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: term.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/term.c,v
retrieving revision 1.39
diff -c -r1.39 term.c
*** term.c 16 Jun 2009 12:31:33 -0000 1.39
--- term.c 14 Jul 2009 19:34:00 -0000
***************
*** 2880,2887 ****
}
/* if 'Sb' and 'AB' are not defined, reset "Co" */
! if (*T_CSB == NUL && *T_CAB == NUL)
T_CCO = empty_option;
/* Set 'weirdinvert' according to value of 't_xs' */
p_wiv = (*T_XS != NUL);
--- 2880,2890 ----
}
/* if 'Sb' and 'AB' are not defined, reset "Co" */
! if (*T_CSB == NUL && *T_CAB == NUL && T_CCO != empty_option)
! {
! vim_free(T_CCO);
T_CCO = empty_option;
+ }
/* Set 'weirdinvert' according to value of 't_xs' */
p_wiv = (*T_XS != NUL);