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: Thu, 05 Dec 2019 14:48:03 +0800	[thread overview]
Message-ID: <87zhg7jmjg.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <83zhgaloc5.fsf@gnu.org>

> Feel free to ask questions about the details you don't understand.

I tried to figure out why the memory consumption is increasing with less
frequent cache clearing.
As I understand, there may be two general reasons of this:
1. Increasing of memory used by the image cache data structure
2. Imperfect implementation of xfree or img->type->free, which are
called by free_image

xfree and img->type->free seem to rely on system libraries and are
unlikely to have such a noticeable memory leaks. 

For the image cache data structure, I can only see one place where it
may request extra memory allocation. It is when the number of images in
the cache exceeds the size of c->images array (= c->size, which is 50 by
default). I observed memory consumption increase even when the frequency
of cache clearing in my test was <50, which makes it unclear for me
where the extra memory consumption is coming from.

> I don't think replacing the system malloc on GNU/Linux systems (let
> alone on others) is an idea we'd like to pursue.  You may have more
> luck playing with mallopt calls in init_alloc_once_for_pdumper
> (assuming your build defines DOUG_LEA_MALLOC).

Do I understand correctly that you refer to emacs compiled with
alternative Doug Lea's implementation of malloc?

Actually, I tried to find a way to compile emacs with alternative
variants of malloc, but I did not find how to do it. 

P.S. I am running emacs with jemalloc for a few days and the overall
impression is that emacs became a lot more responsive. Previously, I
had a slow overtime degradation of delay between commands as emacs
process ran for a long time, up to the point when I can type a whole
sentence until emacs finally displays it on screen. Now, I do not see so
much degradation. 

Best,
Ihor


Eli Zaretskii <eliz@gnu.org> writes:

>> From: Ihor Radchenko <yantar92@gmail.com>
>> Cc: juri@linkov.net, 38345@debbugs.gnu.org
>> Date: Mon, 02 Dec 2019 16:04:46 +0800
>> 
>> > The doc string assumes "normal" operation, it doesn't assume some Lisp
>> > command runs for a long time, thus preventing redisplay.
>> 
>> Sounds counter-intuitive. Elisp commands can run for a long time
>> (pointing at org-agenda). 
>
> Commands that run for a long time make Emacs unresponsive, and
> therefore are a misfeature or a bug.
>
> That said, a command that runs a long time is unlikely to create many
> images, destroying each one before creating the next one, because
> what would be the point of that?
>
> IOW, yours is a scenario that is infrequent at best, IMO.
>
>> I tried to look at the code, but I have to admit that I don't understand
>> the reason. Probably because of my poor C. 
>
> Feel free to ask questions about the details you don't understand.
>
>> In any case, I tried different approach trying to reduce memory
>> fragmentation. Instead of using the default malloc/free, I used jemalloc
>> through LD_PRELOAD. For periodic cache clearing (every 2,10,50, and 100
>> opened/killed images), there was no noticeable difference in the memory
>> consumption. However, when I tried to open a bunch of images all
>> together, killed them, and cleared the cache (as in my initial bug
>> report), the jemalloc instance of emacs showed much lower memory
>> consumption (~240Mb vs 1200Mb). 
>
> I don't think replacing the system malloc on GNU/Linux systems (let
> alone on others) is an idea we'd like to pursue.  You may have more
> luck playing with mallopt calls in init_alloc_once_for_pdumper
> (assuming your build defines DOUG_LEA_MALLOC).





  reply	other threads:[~2019-12-05  6:48 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
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 [this message]
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=87zhg7jmjg.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.