all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs allocates unnecessary memory during scrolling
@ 2006-10-16 14:23 MIYOSHI Masanori
  2006-10-16 15:04 ` Kim F. Storm
  0 siblings, 1 reply; 5+ messages in thread
From: MIYOSHI Masanori @ 2006-10-16 14:23 UTC (permalink / raw)


Emacs 22 on Windows (and probably on other platforms) allocates
unnecessary memory during scrolling.

The following opearaion reproduces the problem.

o emacs -q
o Evaluate (setq scroll-conservatively 10) on the scratch buffer.
o Type `C-h' to view the HELLO file.
o Type `C-n' on to scroll the window.
o Emacs allocates unnecessary memory during scrolling.

Large files which contains multibyte characters should be better
for reproduction.


Findings are:

This changes seems to have revealed the problem.
> 2006-09-06  Kim F. Storm  <storm@cua.dk>
> 
> 	* xdisp.c (pos_visible_p): Remove exact_mode_line_heights_p arg;
> 	so calculate heights even when pos-visible-in-window-p is called
> 	with partially = t.  Don't overshoot last_visible_y in move_it_to.
> 	Return row height and row number in new rowh and vpos args.

In the following call sequences, it->w->ncols_scale_factor is
incremented a number of times.

In xdisp.c:
pos_visible_p()
-> display_mode_line()
-> display_mode_element() ;; case MODE_LINE_DISPLAY:
-> display_string()
-> PRODUCE_GLYPHS()
-> x_produce_glyphs() ;; RIF
-> append_glyph() ;; it->glyph_row->used[area]++
-> IT_EXPAND_MATRIX_WIDTH() ;; it->w->ncols_scale_factor++

In consequence, required_matrix_width() in dispnew.c returns a
large number.  And adjust_glyph_matrix() in dispnew.c allocates
unnecessary large memory for glyphs.


YAMAMOTO Mitsuharu san says:

In xdisp.c:
> static int
> display_mode_line (w, face_id, format)
snip
> {
snip
>   init_iterator (&it, w, -1, -1, NULL, face_id);
>   prepare_desired_row (it.glyph_row);

Before prepare_desired_row(), it.glyph_row->enabled_p happens not
to be 0.  This might be caused by the interruption of redisplay
during scrolling.

Appending the next code before prepare_desired_row() may fix the
problem.
> it.glyph_row->enabled_p = 0;
But he doesn't know the place is appropriate or not.

--
MIYOSHI Masanori

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs allocates unnecessary memory during scrolling
  2006-10-16 14:23 Emacs allocates unnecessary memory during scrolling MIYOSHI Masanori
@ 2006-10-16 15:04 ` Kim F. Storm
  2006-10-18 23:27   ` Chong Yidong
  0 siblings, 1 reply; 5+ messages in thread
From: Kim F. Storm @ 2006-10-16 15:04 UTC (permalink / raw)
  Cc: emacs-devel

MIYOSHI Masanori <miyoshi@meadowy.org> writes:

> Emacs 22 on Windows (and probably on other platforms) allocates
> unnecessary memory during scrolling.


Thank you for the bug report.

Chong, can you look at it, as I don't have time to dig into it right now?

Maybe a fix would be to operate with it->glyph_row = NULL as we do
elsewhere to just do "display measurements", but that's not a trivial
change to display_string and friends.


>
> The following opearaion reproduces the problem.
>
> o emacs -q
> o Evaluate (setq scroll-conservatively 10) on the scratch buffer.
> o Type `C-h' to view the HELLO file.
> o Type `C-n' on to scroll the window.
> o Emacs allocates unnecessary memory during scrolling.
>
> Large files which contains multibyte characters should be better
> for reproduction.
>
>
> Findings are:
>
> This changes seems to have revealed the problem.
>> 2006-09-06  Kim F. Storm  <storm@cua.dk>
>> 
>> 	* xdisp.c (pos_visible_p): Remove exact_mode_line_heights_p arg;
>> 	so calculate heights even when pos-visible-in-window-p is called
>> 	with partially = t.  Don't overshoot last_visible_y in move_it_to.
>> 	Return row height and row number in new rowh and vpos args.
>
> In the following call sequences, it->w->ncols_scale_factor is
> incremented a number of times.
>
> In xdisp.c:
> pos_visible_p()
> -> display_mode_line()
> -> display_mode_element() ;; case MODE_LINE_DISPLAY:
> -> display_string()
> -> PRODUCE_GLYPHS()
> -> x_produce_glyphs() ;; RIF
> -> append_glyph() ;; it->glyph_row->used[area]++
> -> IT_EXPAND_MATRIX_WIDTH() ;; it->w->ncols_scale_factor++
>
> In consequence, required_matrix_width() in dispnew.c returns a
> large number.  And adjust_glyph_matrix() in dispnew.c allocates
> unnecessary large memory for glyphs.
>
>
> YAMAMOTO Mitsuharu san says:
>
> In xdisp.c:
>> static int
>> display_mode_line (w, face_id, format)
> snip
>> {
> snip
>>   init_iterator (&it, w, -1, -1, NULL, face_id);
>>   prepare_desired_row (it.glyph_row);
>
> Before prepare_desired_row(), it.glyph_row->enabled_p happens not
> to be 0.  This might be caused by the interruption of redisplay
> during scrolling.
>
> Appending the next code before prepare_desired_row() may fix the
> problem.
>> it.glyph_row->enabled_p = 0;
> But he doesn't know the place is appropriate or not.
>
> --
> MIYOSHI Masanori

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs allocates unnecessary memory during scrolling
  2006-10-16 15:04 ` Kim F. Storm
@ 2006-10-18 23:27   ` Chong Yidong
  2006-10-19  9:47     ` Kim F. Storm
  0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2006-10-18 23:27 UTC (permalink / raw)
  Cc: MIYOSHI Masanori, emacs-devel

storm@cua.dk (Kim F. Storm) writes:

> MIYOSHI Masanori <miyoshi@meadowy.org> writes:
>
>> Emacs 22 on Windows (and probably on other platforms) allocates
>> unnecessary memory during scrolling.
>
> Thank you for the bug report.
>
> Chong, can you look at it, as I don't have time to dig into it right now?
>
> Maybe a fix would be to operate with it->glyph_row = NULL as we do
> elsewhere to just do "display measurements", but that's not a trivial
> change to display_string and friends.

I'm working on several other bugs at the moment, but I'll get round to
this (unless you fix it first).

It's hard for me to debug a "allocates unnecessary memory" complaint;
the memory difference (as reported by top) doesn't seem obviously
larger to me, nor does there appear to be a performance impact.

>> The following opearaion reproduces the problem.
>>
>> o emacs -q
>> o Evaluate (setq scroll-conservatively 10) on the scratch buffer.
>> o Type `C-h' to view the HELLO file.
>> o Type `C-n' on to scroll the window.
>> o Emacs allocates unnecessary memory during scrolling.
>>
>> Large files which contains multibyte characters should be better
>> for reproduction.
>>
>>
>> Findings are:
>>
>> This changes seems to have revealed the problem.
>>> 2006-09-06  Kim F. Storm  <storm@cua.dk>
>>> 
>>> 	* xdisp.c (pos_visible_p): Remove exact_mode_line_heights_p arg;
>>> 	so calculate heights even when pos-visible-in-window-p is called
>>> 	with partially = t.  Don't overshoot last_visible_y in move_it_to.
>>> 	Return row height and row number in new rowh and vpos args.
>>
>> In the following call sequences, it->w->ncols_scale_factor is
>> incremented a number of times.
>>
>> In xdisp.c:
>> pos_visible_p()
>> -> display_mode_line()
>> -> display_mode_element() ;; case MODE_LINE_DISPLAY:
>> -> display_string()
>> -> PRODUCE_GLYPHS()
>> -> x_produce_glyphs() ;; RIF
>> -> append_glyph() ;; it->glyph_row->used[area]++
>> -> IT_EXPAND_MATRIX_WIDTH() ;; it->w->ncols_scale_factor++
>>
>> In consequence, required_matrix_width() in dispnew.c returns a
>> large number.  And adjust_glyph_matrix() in dispnew.c allocates
>> unnecessary large memory for glyphs.
>>
>>
>> YAMAMOTO Mitsuharu san says:
>>
>> In xdisp.c:
>>> static int
>>> display_mode_line (w, face_id, format)
>> snip
>>> {
>> snip
>>>   init_iterator (&it, w, -1, -1, NULL, face_id);
>>>   prepare_desired_row (it.glyph_row);
>>
>> Before prepare_desired_row(), it.glyph_row->enabled_p happens not
>> to be 0.  This might be caused by the interruption of redisplay
>> during scrolling.
>>
>> Appending the next code before prepare_desired_row() may fix the
>> problem.
>>> it.glyph_row->enabled_p = 0;
>> But he doesn't know the place is appropriate or not.
>>
>> --
>> MIYOSHI Masanori
>
> -- 
> Kim F. Storm <storm@cua.dk> http://www.cua.dk
>
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs allocates unnecessary memory during scrolling
  2006-10-18 23:27   ` Chong Yidong
@ 2006-10-19  9:47     ` Kim F. Storm
  2006-10-20 11:55       ` MIYOSHI Masanori
  0 siblings, 1 reply; 5+ messages in thread
From: Kim F. Storm @ 2006-10-19  9:47 UTC (permalink / raw)
  Cc: MIYOSHI Masanori, emacs-devel


>
>>>
>>> YAMAMOTO Mitsuharu san says:
>>>
>>> In xdisp.c:
>>>> static int
>>>> display_mode_line (w, face_id, format)
>>> snip
>>>> {
>>> snip
>>>>   init_iterator (&it, w, -1, -1, NULL, face_id);
>>>>   prepare_desired_row (it.glyph_row);
>>>
>>> Before prepare_desired_row(), it.glyph_row->enabled_p happens not
>>> to be 0.  This might be caused by the interruption of redisplay
>>> during scrolling.
>>>
>>> Appending the next code before prepare_desired_row() may fix the
>>> problem.
>>>> it.glyph_row->enabled_p = 0;
>>> But he doesn't know the place is appropriate or not.

Looking closer at the code, this is indeed a trivial way to fix the
problem.  

I have committed the change.

Thank you.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs allocates unnecessary memory during scrolling
  2006-10-19  9:47     ` Kim F. Storm
@ 2006-10-20 11:55       ` MIYOSHI Masanori
  0 siblings, 0 replies; 5+ messages in thread
From: MIYOSHI Masanori @ 2006-10-20 11:55 UTC (permalink / raw)


>>>>> In <m3pscok57v.fsf@kfs-l.imdomain.dk>
>>>>>	storm@cua.dk (Kim F. Storm) wrote:
> >>> Appending the next code before prepare_desired_row() may fix the
> >>> problem.
> >>>> it.glyph_row->enabled_p = 0;
> >>> But he doesn't know the place is appropriate or not.

> Looking closer at the code, this is indeed a trivial way to fix the
> problem.

> I have committed the change.

The problem has been fixed.

Thank you.

--
MIYOSHI Masanori

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-10-20 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-16 14:23 Emacs allocates unnecessary memory during scrolling MIYOSHI Masanori
2006-10-16 15:04 ` Kim F. Storm
2006-10-18 23:27   ` Chong Yidong
2006-10-19  9:47     ` Kim F. Storm
2006-10-20 11:55       ` MIYOSHI Masanori

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.