Memory leak in ThumbnailGenerator

Bug #1484914 reported by Florian Boucault
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
High
Alejandro J. Cura
Thumbnailer
Fix Released
High
Albert Astals Cid
qtdeclarative-opensource-src (Ubuntu)
Fix Released
High
Timo Jyrinki

Bug Description

A possible memory leak is exhibited by the attached QML program 'leako.qml'. Run it as is on arale with at least 100 photos in /home/phablet/Pictures/com.ubuntu.camera

$ phablet-shell
$ qmlscene --desktop_file_hint=/usr/share/applications/address-book-app.desktop leako.qml

Running top will show that RES memory usage is rising indefinitely.

Tags: hotfix

Related branches

Revision history for this message
Florian Boucault (fboucault) wrote :
Revision history for this message
Florian Boucault (fboucault) wrote :

When removing the use of the thumbnailer and only loading the images no memory increase is observed.
I attach the Valgrind massif's log as proof.

To run valgrind with massif on the device:
$ valgrind --tool=massif --time-unit=ms --detailed-freq=1 /usr/lib/arm-linux-gnueabihf/qt5/bin/qmlscene --desktop_file_hint=/usr/share/applications/address-book-app.desktop leako.qml

Revision history for this message
Florian Boucault (fboucault) wrote :

Here is a screenshot of the visulisation of the log mentioned just before:
http://people.canonical.com/~kaleo/thumbnailer_leak/no_thumbnailer.png

Revision history for this message
Florian Boucault (fboucault) wrote :

When using the thumbnailer as is done in the sample program, the memory usage increases forever.
I attach the Valgrind massif's log as proof.

Screenshot of a visualisation of that log:
http://people.canonical.com/~kaleo/thumbnailer_leak/thumbnailer.png

From that log it appears that the culprit memory allocation is QImageData::create(...)

Using Valgrind's callgrind we can observe that these are all directly caused by the instantiation of QImage caused in turn by ThumbnailerImageResponse::dbusCallFinished()

Revision history for this message
Florian Boucault (fboucault) wrote :

I attach the log of Valgrind callgrind that can be run like so on the device:

$ valgrind --tool=callgrind /usr/lib/arm-linux-gnueabihf/qt5/bin/qmlscene --desktop_file_hint=/usr/share/applications/address-book-app.desktop leako.qml

Here is a screenshot of its visualisation with kcachegrind:
http://people.canonical.com/~kaleo/thumbnailer_leak/callgraph.png

Revision history for this message
Michi Henning (michihenning) wrote :

This doesn't look like a bug in the thumbnailer per se to me. Is it possible that Qt is doing something wrong?

Certainly, we have tested extensively under valgrind, and all our tests come up clean.

Revision history for this message
Albert Astals Cid (aacid) wrote :

THere's leaks everywhere.

You're doing one thing wrong that is create the texturefactory even if Qt doesn't ask for it, which means it'll never free it.

I am working in patches to fix it.

Changed in qtdeclarative-opensource-src (Ubuntu):
assignee: nobody → Albert Astals Cid (aacid)
Changed in thumbnailer:
status: New → In Progress
Changed in qtdeclarative-opensource-src (Ubuntu):
status: New → In Progress
Revision history for this message
Albert Astals Cid (aacid) wrote :

There's three different patches needed, the branch linked for the thumbnailer and also
https://codereview.qt-project.org/#/c/123420/ and https://codereview.qt-project.org/#/c/123432/ (both still on review upstream)

That reduces a lot the memory usage here and can't find any leak more using valgrind

Revision history for this message
Michi Henning (michihenning) wrote :

Thanks for picking us up on that one and stepping in to help!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:thumbnailer/devel at revision 254, scheduled for release in thumbnailer, milestone Unknown

Changed in thumbnailer:
status: In Progress → Fix Committed
Bill Filler (bfiller)
Changed in canonical-devices-system-image:
milestone: none → ww40-2015
assignee: nobody → Alejandro J. Cura (alecu)
importance: Undecided → High
Revision history for this message
Albert Astals Cid (aacid) wrote :

Timo: The upstream Qt patches have been approved and merged, can we get them distro patched?

Changed in qtdeclarative-opensource-src (Ubuntu):
assignee: Albert Astals Cid (aacid) → Timo Jyrinki (timo-jyrinki)
importance: Undecided → High
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Yes. One qtdeclarative update is currently in the pipeline, this'd be for the next one.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/landing-026 now has the 5.4.1-1ubuntu10 - please test regarding this bugfix and eg Unity 8 in general.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Tried the silo, can't find any problem with it and the memory leaks seem to be gone as far as i can see.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Ignore this comment.

Sorry for the noise, testing new Launchpad filter additions to bug e-mails.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qtdeclarative-opensource-src - 5.4.2-1ubuntu6

---------------
qtdeclarative-opensource-src (5.4.2-1ubuntu6) wily; urgency=medium

  * debian/patches/Fix-memory-leak-when-QQuickPixmapReply-Event-is-dele.patch
    debian/patches/Fix-memory-leak-when-using-async-image-providers.patch:
    - Fix memory leaks (LP: #1484914)

 -- Timo Jyrinki <email address hidden> Tue, 01 Sep 2015 12:02:43 +0000

Changed in qtdeclarative-opensource-src (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Also in vivid overlay since yesterday:

qtdeclarative-opensource-src (5.4.1-1ubuntu10) vivid; urgency=medium

  * debian/patches/Fix-memory-leak-when-QQuickPixmapReply-Event-is-dele.patch
    debian/patches/Fix-memory-leak-when-using-async-image-providers.patch:
    - Fix memory leaks (LP: #1484914)

 -- Timo Jyrinki <email address hidden> Fri, 28 Aug 2015 10:04:35 +0000

Changed in canonical-devices-system-image:
status: New → Fix Committed
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

still waiting for thumbnailer fix

Changed in canonical-devices-system-image:
status: Fix Committed → In Progress
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

there is a chance this fix improved some overall performance so should consider for early release

tags: added: hotfix6
Revision history for this message
Michi Henning (michihenning) wrote :

We have two more branches to go into the next release. We'll putting things into a silo on Tuesday.

Revision history for this message
Michi Henning (michihenning) wrote :

Sitting in silo 15 now. We haven't run the test plan yet, but I don't anticipate any issues.

Changed in thumbnailer:
status: Fix Committed → Fix Released
tags: added: hotfix
removed: hotfix6
Changed in canonical-devices-system-image:
status: In Progress → Fix Committed
Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.