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

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



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

Here's one non-portable way of preventing the OOM, and making the rm -rf
go quickly.

Should H_ISIZE be changed to the page size when USE_MMAP is defined, or
is there a reason to keep it the sizeof(union mem_align) ?

--- orig/Src/mem.c
+++ mod/Src/mem.c
@@ -379,8 +379,8 @@
 {
     Heap h, ph;
 
-    old = (old + H_ISIZE - 1) & ~(H_ISIZE - 1);
-    new = (new + H_ISIZE - 1) & ~(H_ISIZE - 1);
+    old = (old + 4096 - 1) & ~(4096 - 1);
+    new = (new + 4096 - 1) & ~(4096 - 1);
 
     if (old == new)
 	return p;





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