Subject: bug#61763: 30.0.50; Image Cache Size growth

From: Eli Zaretskii <[email-masked]>
Date: Fri, 24 Feb 2023 22:43:10 +0200

> From: Manuel Giraud <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 24 Feb 2023 21:27:41 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> [...]
> 
> >> Can you reproduce (if you have time)?
> >
> > Not sure what I need to reproduce.  I've visited 6 images of 2 MiB
> > each and Memory Report says I have 581 MiB in my image cache.
> > Meanwhile the memory footprint of the Emacs process is 350 MiB.  Is
> > this what you wanted to see?
> 
> Ok.  So in the same ballpark.  I thought there was something wrong on my
> setup.
> 
> Why I think this growth is wrong is because it seems high.  And if I'm
> browsing some images in Emacs, I'm getting a "Memory exhausted (restart
> Emacs)" message after only 20 or 30 images.

JPEG compression is very good, it routinely compresses images with
ratios of 10:1 to 20:1.  If I use djpeg to convert the 2 MiB images I
used into BMP, I get 36 MiB BMP files -- that's a 1:18 expansion
ratio.  And Emacs converts each image to a pixmap for display, which
is basically similar to what I did.  Multiply that by 20 or 30, and
you get the numbers you see, I think.

The solution is to enlarge the VM for your machine (by enlarging swap,
for example).  If you don't keep those images displayed in windows,
lowering image-cache-eviction-delay might also help.