Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: argv subscript range uses too many memory
On Tue, Nov 20, 2012 at 10:24:15AM -0800, Bart Schaefer wrote:
> So what about the following? This is still probably incomplete because
> (ARENA_SIZEOF(fheap) >= (size + fheap->used)) seems like the wrong test
> for whether to begin the search at fheap, but I'm curious whether this
> improves the garbage collection behavior.
>
> Index: Src/mem.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/mem.c,v
> retrieving revision 1.20
> diff -u -r1.20 mem.c
> --- Src/mem.c 14 May 2011 17:23:23 -0000 1.20
> +++ Src/mem.c 20 Nov 2012 18:12:41 -0000
> @@ -507,9 +507,11 @@
>
> /* find a heap with enough free space */
>
> - for (h = ((fheap && ARENA_SIZEOF(fheap) >= (size + fheap->used))
> - ? fheap : heaps);
> - h; h = h->next) {
> + h = (fheap && ARENA_SIZEOF(fheap) >= (size + fheap->used)) ? fheap : heaps;
> + for (fheap = NULL; h; h = h->next) {
> + /* track the first heap with free space in fheap */
> + if (!fheap && h->used < ARENA_SIZEOF(h))
> + fheap = h;
> if (ARENA_SIZEOF(h) >= (n = size + h->used)) {
> void *ret;
>
> @@ -566,7 +568,8 @@
> hp->next = h;
> else
> heaps = h;
> - fheap = h;
> + if (!fheap)
> + fheap = h;
>
> unqueue_signals();
> #ifdef ZSH_HEAP_DEBUG
I have tried this patch. Looks like with this patch on 5.0, both
for i in {1..700000}; do true; done
and
set -- ~/**/*
while ((ARGC>=3))
do
print -- "${argv[1,3]}"
shift 3
done
will run very slow, but the memory problem is solved at the
sametime.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author