[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Accelerating Emacs?
From: |
David Kastrup |
Subject: |
Re: Accelerating Emacs? |
Date: |
Fri, 28 Oct 2005 14:08:29 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
"Herbert Euler" <herberteuler@hotmail.com> writes:
>>From: Eli Zaretskii <eliz@gnu.org>
>>To: help-gnu-emacs@gnu.org
>>Subject: Re: Accelerating Emacs?
>>Date: Fri, 28 Oct 2005 10:23:46 +0200
>
> Now I must show what I did. First, I wrote a Lisp program to generate
> random data:
>
> (let ((i 0))
> (while (< i 20000)
> (let ((j 0) s)
> (while (< j 10)
> (setq s (concat s (char-to-string (+ 50 (random 50))))
> j (1+ j)))
> (insert s "\n"))
> (setq i (1+ i))))
This is not good in any programming language, as it has quadratic time
behavior.
_Buffers_ are the data structures for inserting text, not strings. So
you better write:
(dotimes (i 20000)
(dotimes (j 10)
(insert-char (+ 50 (random 50))))
(insert-char ?\C-j))
> I found Emacs used more and more memory when generating random data,
> so did when it replacing. These memory is released after Emacs
> finishes its job. Is this because Emacs operating buffer residing in
> memory?
No, it is because of nonsensical accumulation of strings which are
only garbage-collected from time to time.
> This happens when I am testing a 100MB size file. I go to the beginning
> of the file, press C-SPACE, then go to the end of the file, press M-w.
Don't do that, then. Use delete-region instead of kill-region, or the
region will end up in the kill ring, where it still occupies memory.
And you might want to disable the undo history as well.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Re: Accelerating Emacs?,
David Kastrup <=
Re: Accelerating Emacs?, Thien-Thi Nguyen, 2005/10/28
Re: Accelerating Emacs?, Alan Mackenzie, 2005/10/28