Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#245678: zsh: built-in rm -rf fills up the memory



> I think I've found the problem.  Here's an excerpt from an strace of
> the zsh/files rm -rf going wild.  There are 55 or 56 such calls to mmap
> for every length value.  Thus it appears that zsh is allocating
> considerably more memory than it needs.

More on this:

recursivecmd_dorec() calls hrealloc() for each target file, incrementing
size accordingly.  hrealloc() rounds the new length up to the nearest
page boundary, and mmaps a new Heap for each file.

So, for example, if you have a directory with one hundred files with
9-byte filenames, zsh might allocate one hundred 4096-byte areas.  If
you have several thousand files with 70- to 80-byte filenames, zsh
might allocate over 50 4096-byte areas, over 50 8192-byte areas, and so
on.

Now, should this be fixed by making hrealloc() smarter or
recursivecmd_dorec() more efficient?



Messages sorted by: Reverse Date, Date, Thread, Author