all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thievol@posteo.net>
To: Stefan Kangas <stefan@marxist.se>
Cc: 51763@debbugs.gnu.org
Subject: bug#51763: 27.2; Displaying many images take all memory
Date: Thu, 11 Nov 2021 11:22:49 +0000	[thread overview]
Message-ID: <8735o39bad.fsf@posteo.net> (raw)
In-Reply-To: <CADwFkmnqTbcT-V6WLb4EQ=7ZEKO2PfmiQRDRtWSDkHd6JrYL=g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2287 bytes --]


Stefan Kangas <stefan@marxist.se> writes:

> Thierry Volpiatto <thievol@posteo.net> writes:
>
>> I see you changed image-dired to use image-mode in emacs-29 instead of using like
>> before image-magick.  That's fine I used the same approach two years ago
>> in Helm, but switched back quickly to image-dired because it was taking
>> all memory and it was not recoverable until I kill emacs. I thought it
>> was my fault but I see new image-dired in emacs-29 have same problem:
>>
>> 1) emacs -Q
>> 2) Open a large image directory with dired
>> 3) Open files one by one with C-t i until memory is full (use f3 C-t i
>> C-n f4 etc...). Memory starts to grow seriously after around 70 files
>> for me.
>>
>> Killing the image-dired buffer changes nothing, I have to restart emacs
>> to recover memory.
>
> Thanks for the bug report!
>
> In principle there should be no difference between the two: in both
> cases we need to cache the same upscaled image.
>
> However, we currently have an issue with our built-in image scaling that
> we cache the image both before resizing and after.  I suspect that this
> is the explanation for the higher memory usage you see.
>
> See this comment in `image--scale-within-limits-p':
>
>             ;; Note: `image-size' looks up and thus caches the
>             ;; untransformed image.  There's no easy way to
>             ;; prevent that.
>
> and the relevant code in image.c that verifies this.
>
> I believe that we could fix this in image.c.  I don't think it's
> necessarily very hard, but it does take some coding.

Sorry but this is out of my scope.

> However, I'm curious what you mean when you say that it "never" frees
> the memory.  What happens if you set `image-cache-eviction-delay' to
> some very low value like 5 seconds?

Didn't yet tried this one.

> AFAIU, calling `clear-image-cache' should also the free memory unless we
> have a memory leak.  You could also call this function from your code.
> Does calling this function free the memory for you?

Yes it does 🙂.  I didn't know this function (BTW what about renaming to
`image-clear-cache`), works great with my code, perhaps you can do the
same in dired (we use more or less similar code).

Thanks.

-- 
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]

  reply	other threads:[~2021-11-11 11:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11  9:00 bug#51763: 27.2; Displaying many images take all memory Thierry Volpiatto
2021-11-11  9:50 ` Stefan Kangas
2021-11-11 11:22   ` Thierry Volpiatto [this message]
2021-11-11 17:33     ` Stefan Kangas
2021-11-11 18:11       ` Thierry Volpiatto
2021-11-11 12:39   ` Lars Ingebrigtsen
2021-11-11 17:33     ` Stefan Kangas
2021-11-12  3:30       ` Lars Ingebrigtsen
2021-11-12  4:03         ` Stefan Kangas
2021-11-12  6:24           ` Lars Ingebrigtsen
2021-11-13  7:32       ` Thierry Volpiatto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735o39bad.fsf@posteo.net \
    --to=thievol@posteo.net \
    --cc=51763@debbugs.gnu.org \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.