Subject: bug#26952: 25.1; loops eating all memory while yanking big rectangle

From: Eli Zaretskii <[email-masked]>
Date: Sun, 21 May 2017 18:28:12 +0300

> From: [email-masked]
> Cc: [email-masked],  [email-masked]
> Date: Sat, 20 May 2017 15:27:39 -0400
> 
> > So you are saying that inserting 90MB worth of text into a buffer
> > makes Emacs 25.2 run out of 1GB of memory, due to inefficiencies of
> > the malloc implementation?
> 
> When it's inserted in small chunks, yes, I think so.  What seems to
> happen is that the buffer gap keeps getting realloc'd to be slightly
> bigger, and the deallocated chunks don't get reused.
> 
> > (Here on Windows it produces a 230MB Emacs
> > session, but the Windows build uses the moral equivalent of mmap for
> > allocating buffer text.)
> 
> Neither master nor emacs-25 are using mmap (according to configure
> output), but I guess the "hybrid" or relocating allocaters are smart
> enough to handle this case.

I cannot see why.  AFAIK, the only difference between using the hybrid
allocation and not using it is before Emacs is dumped; after that both
use the same system malloc.  So if the hybrid malloc fixed this, the
problem is somehow related to the memory allocation before dumping.
Maybe reallocating a gap that was allocated before dumping somehow
exposes a bug?

Paul, is it feasible to back-port the hybrid allocation to the
emacs-25 branch?  This sounds like a nasty bug, so if we can safely
fix it, I think we ought to release Emacs 25.3 with just this issue
fixed.  WDYT?