From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Emacs allocates unnecessary memory during scrolling Date: Mon, 16 Oct 2006 17:04:38 +0200 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1161011184 21263 80.91.229.2 (16 Oct 2006 15:06:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Oct 2006 15:06:24 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 16 17:06:15 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GZU2P-00037f-P9 for ged-emacs-devel@m.gmane.org; Mon, 16 Oct 2006 17:05:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GZU2P-0007H4-BD for ged-emacs-devel@m.gmane.org; Mon, 16 Oct 2006 11:05:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GZU26-0007AH-7T for emacs-devel@gnu.org; Mon, 16 Oct 2006 11:05:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GZU21-00072G-9O for emacs-devel@gnu.org; Mon, 16 Oct 2006 11:05:37 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GZU21-000724-0r for emacs-devel@gnu.org; Mon, 16 Oct 2006 11:05:33 -0400 Original-Received: from [195.41.46.235] (helo=pfepa.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GZUB9-0004t4-Ah for emacs-devel@gnu.org; Mon, 16 Oct 2006 11:14:59 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (unknown [80.165.4.124]) by pfepa.post.tele.dk (Postfix) with SMTP id 4BC1DFAC049; Mon, 16 Oct 2006 17:05:22 +0200 (CEST) Original-To: MIYOSHI Masanori In-Reply-To: (MIYOSHI Masanori's message of "Mon\, 16 Oct 2006 23\:23\:06 +0900") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:60792 Archived-At: MIYOSHI Masanori 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 >> >> * 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 http://www.cua.dk