[okular] [Bug 388854] Okular uses a very large amount of RAM for caching
Tobias Deiminger
bugzilla_noreply at kde.org
Mon Jul 2 23:11:35 UTC 2018
https://bugs.kde.org/show_bug.cgi?id=388854
--- Comment #30 from Tobias Deiminger <haxtibal at posteo.de> ---
(In reply to Albert Astals Cid from comment #28)
> *BUT* this may actually be a manifestation of "glibc is useless and doesn't
> actually free memory when you tell it to" that i workarounded at
> https://cgit.kde.org/okular.git/commit/
> ?id=95bc29a76fc1f93eaabe5383d934644067dfc884
That's well possible. I did some memory forensics with attachment 109856
loaded. The observations could be explained by glibc not freeing memory.
Important note in advance: Yes, Okular caches pages. But it stores them as
QPixmaps (e.g., see PagePrivate::m_pixmaps). This means, at least on X11, the
image payload is not kept in Okulars heap. QPixmap objects are just wrappers
around X11 pixmap handles [0]. The raw image data is stored in memory managed
by the X11 server, not in Okulars heap.
Following this theory, I shouldn't be able to find bitmaps in heap.
I iterated over all malloc chunks in a gdb session (using gdb gef with some
customization), and checked for suspicious chunks (by vtable, by size). There
were several chunks of size > 4 MiB, flagged as "in use". Such big chunks could
be bitmaps, just guessing by their sheer size. I dumped the memory range of
such a chunk into a file, like:
(gdb) dump binary memory /tmp/dump.bin 0x55a80d790560 0x55A80DB71BF0
When opening /tmp/dump.bin in Gimp as raw image, and playing around with width
and height a bit, it looked like attachment 113727. Quite clear case. This is
either the reminder of a page bitmap, or Maxwells Daemon did a quite good job
:)
What does this tell us? Imo it tells there's the inner bitmap of a QImage
hanging around in the heap, a thing that shouldn't be. QImages are only used
temporarily, when they're sent from the rendering thread over a queued
connection to the main thread. After transforming them into QPixmap (in
Generator::generatePixmap), they should be freed. If they are not, this could
for example mean there are some QImages stuck in the queue, or it could be some
glibc behavior as mentioned by Albert.
Albert, Oliver: If you think I'm on the wrong track, please stop me from
digging deeper.
[0] ftp://www.x.org/pub/X11R7.7/doc/man/man3/xcb_create_pixmap.3.xhtml
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Okular-devel
mailing list