[Top][All Lists]

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

bug#33275: 27.0.50; Image cache pruning

From: Lars Ingebrigtsen
Subject: bug#33275: 27.0.50; Image cache pruning
Date: Mon, 05 Nov 2018 15:07:30 +0100

I was writing a function to do some image processing, and after it had
run a few minutes, the Emacs window disappeared.

After poking around a bit, it turned out that Emacs was killed by the
out-of-memory task.  I though that Emacs must have a serious memory leak
somewhere, but `garbage-collect' didn't really seem to have anything
mysterious in it.

So after trying various things, it turned out that you can kill Emacs by
doing this:

(dolist (file (directory-files "/directory/with/many/images" t "png$"))
  (image-size (create-image file) t))

and this is because `image-size' puts the image into the image cache.
Calling `clear-image-cache' releases the memory.

I think putting it into the cache is the right thing to do, because if
you're calling `image-size' on a file, then nine out of ten times you
want to display it, and my use case here is atypical (batch-processing
of a large number of huge images), but it's still not optimal that you
can crash Emacs in this way.

So perhaps the cache should be pruned more aggressively according to
some smart algorithm or other?  Or, at the very least, an
innocuous-looking function like `image-size' should note in the doc
string should note what's going on and recommend calling `image-flush'
afterwards if we don't want to cache the image?

In GNU Emacs 27.0.50 (build 50, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2018-08-26 built on stories
Repository revision: 5c642b2dc1b666ae488225b76251750a8cf331be
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description: Debian GNU/Linux 9 (stretch)

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

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