all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 38345@debbugs.gnu.org, juri@linkov.net
Subject: bug#38345: 27.0.50; Permanent increase in memory consumption after opening images (or pdfs)
Date: Fri, 29 Nov 2019 01:27:39 +0800	[thread overview]
Message-ID: <87zhgflxmc.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <83sgm8ox3g.fsf@gnu.org>

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

> As I explained elsewhere, unless you call clear-image-cache from Lisp,
> the only place we do that automatically is when the number of
> redisplay cycles since last time the image cache was cleared becomes
> greater than 101.  This, no matter how low is the value of
> image-cache-eviction-delay, it will have no effect until we've done
> 101 redisplay cycles.  And your loop above does just one.

Hmm. I saw that email, but did not understand it well. I thought that
cache clearing is triggered not later than image-cache-eviction-delay,
but can be triggered earlier if the number of cycles is more than 101...

The behaviour you describe does not follow the docstring:
> "*Maximum time* after which images are removed from the cache.
> ...
> If the cache contains
> a large number of images, the actual eviction time may be shorter.
> ...

Also, I repeated my tests manually calling image-clear-cache every Nth
image. Every invocation of image-clear-cache does reduce the memory
consumption, but there is always some residual remaining unrealeased
(see the attached images). The residual seems to scale with the number
of images in the cache before clearing.
Suggestion: we may be able to control the memory consumption if the
image-clear-cache is not only triggered by the time and display cycles,
but also by the cache size. If a variable like image-cache-max-size is
exposed to elisp, the user may be able to deal with similar memory
consumption issues just by reducing the variable value.
Though, indeed, there should be no residual memory in ideal scenario. 

Regards,
Ihor


[-- Attachment #2: images-seq-2ndclear.png --]
[-- Type: image/png, Size: 22264 bytes --]

[-- Attachment #3: images-seq-10thclear.png --]
[-- Type: image/png, Size: 22770 bytes --]

[-- Attachment #4: images-seq-50thclear.png --]
[-- Type: image/png, Size: 23355 bytes --]

[-- Attachment #5: images-seq-100thclear.png --]
[-- Type: image/png, Size: 22807 bytes --]

[-- Attachment #6: Type: text/plain, Size: 1542 bytes --]





Eli Zaretskii <eliz@gnu.org> writes:

>> From: Ihor Radchenko <yantar92@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, 38345@debbugs.gnu.org
>> Date: Thu, 28 Nov 2019 09:38:34 +0800
>> 
>> #+begin_sec emacs-lisp
>> (dolist (file (directory-files "~/Tosort/pictures&photos/" 'full ".*jpg"))
>>   (find-file file)
>>   (mapc #'kill-buffer (seq-filter (apply-partially #'string-match ".+.jpg$") (mapcar #'buffer-name (buffer-list))))
>>   (garbage-collect)
>>   (clear-image-cache t))
>> #+end_src
>> 
>> The resulting memory consumption graph is attached.
>> The memory increase almost disappeared (remaining heap size becomes
>> ~40Mb in comparison ~400Mb in the version with just garbage collect).
>> 
>> Just calling (clear-image-cache) after cycling over opening/killing
>> the image buffers still results in ~400Mb (it has no effect, basically).
>> 
>> The above result is confusing since the all the code I tried to run so
>> far had (setq image-cache-eviction-delay 5). Since, cycling over all the
>> images usually took >1min, cache clearing supposed to happen at least
>> several times during opening/killing the image buffers.
>
> As I explained elsewhere, unless you call clear-image-cache from Lisp,
> the only place we do that automatically is when the number of
> redisplay cycles since last time the image cache was cleared becomes
> greater than 101.  This, no matter how low is the value of
> image-cache-eviction-delay, it will have no effect until we've done
> 101 redisplay cycles.  And your loop above does just one.


  reply	other threads:[~2019-11-28 17:27 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23 14:37 bug#38345: 27.0.50; Permanent increase in memory consumption after opening images (or pdfs) Ihor Radchenko
     [not found] ` <handler.38345.B.15745199896049.ack@debbugs.gnu.org>
2019-11-23 14:44   ` bug#38345: Acknowledgement (27.0.50; Permanent increase in memory consumption after opening images (or pdfs)) Ihor Radchenko
2019-11-23 14:48 ` bug#38345: 27.0.50; Permanent increase in memory consumption after opening images (or pdfs) Lars Ingebrigtsen
2019-11-23 15:12   ` Ihor Radchenko
2019-11-23 14:50 ` Eli Zaretskii
2019-11-23 15:18   ` Ihor Radchenko
2019-11-23 15:45     ` Eli Zaretskii
2019-11-23 16:04       ` Ihor Radchenko
2019-11-23 16:34         ` Eli Zaretskii
2019-11-23 17:33           ` Ihor Radchenko
2019-11-23 17:51             ` Eli Zaretskii
2019-11-25 16:10 ` Eli Zaretskii
2019-11-26 15:21   ` Ihor Radchenko
2019-11-26 15:55     ` Eli Zaretskii
2019-11-26 16:24       ` Ihor Radchenko
2019-11-27 21:17     ` Juri Linkov
2019-11-28  1:38       ` Ihor Radchenko
2019-11-28 12:35         ` Lars Ingebrigtsen
2019-11-28 13:11           ` Ihor Radchenko
2019-11-28 15:10         ` Eli Zaretskii
2019-11-28 17:27           ` Ihor Radchenko [this message]
2019-11-28 18:44             ` Eli Zaretskii
2019-12-02  8:04               ` Ihor Radchenko
2019-12-02 15:49                 ` Eli Zaretskii
2019-12-05  6:48                   ` Ihor Radchenko
2019-12-05 14:52                     ` Eli Zaretskii
2019-12-06  1:34                       ` Noam Postavsky
2019-12-06  7:52                         ` Eli Zaretskii
2019-12-07 19:25                           ` Noam Postavsky
2019-12-07 19:39                             ` Eli Zaretskii
2019-12-13 12:12                               ` Should use of mallopt depend on DOUG_LEA_MALLOC? (WAS: bug#38345) Noam Postavsky
2019-12-13 14:38                                 ` Eli Zaretskii
2019-12-13 15:22                                   ` Should use of mallopt depend on DOUG_LEA_MALLOC? Stefan Monnier
2019-12-13 21:55                                     ` Paul Eggert
2019-12-14  7:59                                       ` Eli Zaretskii
2019-12-16  6:18                       ` bug#38345: 27.0.50; Permanent increase in memory consumption after opening images (or pdfs) Ihor Radchenko
2019-12-16 16:30                         ` Eli Zaretskii
2020-08-02 18:14                           ` Lars Ingebrigtsen
2020-08-02 22:52                             ` Ihor Radchenko
2020-08-03  6:10                               ` Lars Ingebrigtsen

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=87zhgflxmc.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me \
    --to=yantar92@gmail.com \
    --cc=38345@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    /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.