summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-10-24 13:43:21 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-10-24 13:43:21 -0700
commit506d5923802a930f24dd264588a8d33c05ed085b (patch)
tree50704feee37108f2f091bcfbc291beaa962482d1 /Src
parent272119b774a5227e8778e5f86b4a519db89ab0fa (diff)
downloadzsh-506d5923802a930f24dd264588a8d33c05ed085b.tar.gz
zsh-506d5923802a930f24dd264588a8d33c05ed085b.tar.xz
zsh-506d5923802a930f24dd264588a8d33c05ed085b.zip
36943: restore scan for reclaimable blocks in freeheap()
That scan had been removed by 36834, but testing showed memory usage
climbing too high in cases where a new arena was always added at the
end of the heap list.
Diffstat (limited to 'Src')
-rw-r--r--Src/mem.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Src/mem.c b/Src/mem.c
index 68bd76740..158ad9641 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -340,9 +340,15 @@ freeheap(void)
      * and performance goes to hell.
      *
      * Therefore, we defer freeing the most recently allocated arena until
-     * we reach popheap().  This may fail to reclaim some space in earlier
-     * arenas.
+     * we reach popheap().
      *
+     * However, if the arena to which fheap points is unused, we want to
+     * reclaim space in earlier arenas, so we have no choice but to do the
+     * sweep for a new fheap.
+     */
+    if (fheap && !fheap->sp)
+       fheap = NULL;   /* We used to do this unconditionally */
+    /*
      * In other cases, either fheap is already correct, or it has never
      * been set and this loop will do it, or it'll be reset from scratch
      * on the next popheap().  So all that's needed here is to pick up