emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory leak in display code?


From: Richard Stallman
Subject: Memory leak in display code?
Date: Fri, 28 Dec 2001 22:31:33 -0700 (MST)

If I type C-x 2 C-x 2, then drag the upper mode line down
until the bottom two windows are as small as possible
and then keep trying to drag, those windows eventually become
just 2 lines tall (a bug since window-min-height is 4);
and then Emacs says it has run out of memory.

That happens within a call to xrealloc here in adjust_glyph_matrix

              row->glyphs[LEFT_MARGIN_AREA]
                = (struct glyph *) xrealloc (row->glyphs[LEFT_MARGIN_AREA],
                                             (dim.width
                                              * sizeof (struct glyph)));

(row->glyphs contains four zeros.)

I saw this with a breakpoint at memory_full.  With no breakpoint
there, Emacs actually crashes in the display code later on, trying to
display the buffer that says memory is full.  Some of the glyph data
structure is missing.  So maybe the code that allocates this
structure or uses it needs to be defensive.

I find something suspicious about the "memory full" error--I am
surprised that this operation can use up memory so fast.  But I don't
know how to check whether memory is really full.

If memory has really been exhausted, I suspect there is a memory leak
in dealing with the glyph data structure, such that it is not freed
when it ought to be.  Continuing to try to drag the mode line down
causes windows to be deleted and then resurrected with
set-window-configuration.  Perhaps in that path the structures
are allocated again without being freed.  Gerd, could you see
if that is so?

I don't see anything in adjust_glyph_matrix that can free any
of the glyph matrix structure.


I have a fix for the bug that shrinks the windows to a height of 2,
but I won't check it in just yet, since it seems to mask the more
serious bugs described above.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]