unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33275: 27.0.50; Image cache pruning
@ 2018-11-05 14:07 Lars Ingebrigtsen
  2018-11-05 16:05 ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Lars Ingebrigtsen @ 2018-11-05 14:07 UTC (permalink / raw)
  To: 33275


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






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

end of thread, other threads:[~2019-09-21  8:18 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-05 14:07 bug#33275: 27.0.50; Image cache pruning Lars Ingebrigtsen
2018-11-05 16:05 ` Eli Zaretskii
2018-11-05 16:18   ` Lars Ingebrigtsen
2018-11-05 16:23     ` Eli Zaretskii
2018-11-05 16:35       ` Lars Ingebrigtsen
2018-11-05 17:27         ` Eli Zaretskii
2018-11-05 17:36           ` Lars Ingebrigtsen
2018-11-05 17:48             ` Lars Ingebrigtsen
2018-11-05 18:14               ` Eli Zaretskii
2018-11-05 18:35                 ` Eli Zaretskii
2018-11-05 19:13                   ` Lars Ingebrigtsen
2018-11-05 19:28                     ` Eli Zaretskii
2018-11-09 12:22                       ` Lars Ingebrigtsen
2018-11-06 15:40               ` Eli Zaretskii
2018-11-09 12:26                 ` Lars Ingebrigtsen
2018-11-10  9:48                   ` Eli Zaretskii
2019-09-21  8:18                     ` Lars Ingebrigtsen
2018-11-05 18:18             ` Eli Zaretskii
2018-11-05 19:06               ` Lars Ingebrigtsen
2018-11-05 19:24                 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).