mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 13:45:15 -07:00
vim-patch:8.2.0061: the execute stack can grow big and never shrinks
Problem: The execute stack can grow big and never shrinks.
Solution: Reduce the size in gargage collect.
3fbcc128cb
This commit is contained in:
parent
ded2925b40
commit
de72f9098a
@ -4188,6 +4188,23 @@ bool garbage_collect(bool testing)
|
||||
garbage_collect_at_exit = false;
|
||||
}
|
||||
|
||||
// The execution stack can grow big, limit the size.
|
||||
if (exestack.ga_maxlen - exestack.ga_len > 500) {
|
||||
// Keep 150% of the current size, with a minimum of the growth size.
|
||||
int n = exestack.ga_len / 2;
|
||||
if (n < exestack.ga_growsize) {
|
||||
n = exestack.ga_growsize;
|
||||
}
|
||||
|
||||
// Don't make it bigger though.
|
||||
if (exestack.ga_len + n < exestack.ga_maxlen) {
|
||||
size_t new_len = (size_t)exestack.ga_itemsize * (size_t)(exestack.ga_len + n);
|
||||
char *pp = xrealloc(exestack.ga_data, new_len);
|
||||
exestack.ga_maxlen = exestack.ga_len + n;
|
||||
exestack.ga_data = pp;
|
||||
}
|
||||
}
|
||||
|
||||
// We advance by two (COPYID_INC) because we add one for items referenced
|
||||
// through previous_funccal.
|
||||
const int copyID = get_copyID();
|
||||
|
Loading…
Reference in New Issue
Block a user