Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Loader leaks memory
Qt 6.11 is out! See what's new in the release blog

QML Loader leaks memory

Scheduled Pinned Locked Moved QML and Qt Quick
28 Posts 11 Posters 29.7k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    altera_2011
    wrote on last edited by
    #11

    Yes, that is what I tried as well but sadly due to the memory constraints that pushed us up right to the maximum. Which caused more out of memory errors.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #12

      Are you sure the memory leaks are not because you forgot to free memory you allocated on the heap ?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        altera_2011
        wrote on last edited by
        #13

        No I'm 100% sure on top of that I've recreated the leak using 2 empty QMLs

        https://bugreports.qt-project.org/browse/QTBUG-26032?focusedCommentId=179280#comment-179280

        1 Reply Last reply
        0
        • A Offline
          A Offline
          altera_2011
          wrote on last edited by
          #14

          One thing that I did notice is that when I add

          @m_View->engine()->clearComponentCache();@

          The leak is 10 times worse!

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #15

            This is all rather scary. Happens for me, too - due to big JPGs/PNGs loaded, it adds +40MB per unload.

            (Z(:^

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #16

              Does it happen only on Qt 4.7.4 or also on Qt 4.7.3 Qt 4.8 and Qt 5 ?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                altera_2011
                wrote on last edited by
                #17

                4.7.4 + 4.8.2 I have not tested 5 since we require Windows CE support.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #18

                  In my case:

                  4.7.4, 4.8.1 - QtQuick 1.
                  Qt5.0.0 - QtQuick 2.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #19

                    I also saw it on embedded linux.
                    Its a very serious leak.
                    It happens all the time there is a loading of new qml pages

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #20

                      We found that the reason for the memory leak is Qt's function:

                      QDeclarativeEngine::clearComponentCache()

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        andre
                        wrote on last edited by
                        #21

                        Please report a bug in the bug tracker then. Not many Qt Developers (those building Qt itself, not so much those using it) read these forums.

                        1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #22

                          Can you please send me a link ?

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            andre
                            wrote on last edited by
                            #23

                            The "bugtracker":https://bugreports.qt-project.org we usually call "Jira" (after the name of the system it is using). If you report a bug, please:

                            Put a link to this forum topic in the bugreport, and

                            Put a link to the bugreport in this forum topic.

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              antonio
                              wrote on last edited by
                              #24

                              somebody has resolved this issue?

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                chrisadams
                                wrote on last edited by
                                #25

                                Firstly, why is anyone calling clearComponentCache() in QtQuick 1? You have to be extremely careful about the circumstances in which you do so, or all sorts of craziness can occur.

                                In QtQuick2, I seem to recall that we added / changed the functionality significantly (and updated the documentation) to clearly reflect what those functions should be used for and how.

                                It's been a while, though, and my memory isn't too great. If someone can link the JIRA task I can take a brief look, but I can't promise to spend too much time on it, unfortunately.

                                Cheers,
                                Chris.

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  antonio
                                  wrote on last edited by
                                  #26

                                  I'm not sure if there are leaks.

                                  I added to my qml pages:
                                  @
                                  Component.onDestruction:{
                                  componentX.destroy()
                                  componentY.destroy()
                                  componentZ.destroy()
                                  }
                                  @
                                  for every nested component

                                  and I'm using http://www.sikuli.org/ to test the complete flow (6 pages with many images). I had used my app 2000 times and there is not delay or crash.

                                  Hope this helps

                                  1 Reply Last reply
                                  0
                                  • ? Offline
                                    ? Offline
                                    A Former User
                                    wrote on last edited by
                                    #27

                                    Instead of calling app.exec() exec your event loop like this and see if it still leaks.

                                    {
                                    app.processEvents(..);
                                    view->engine()->collectGarbage();
                                    view->engine()->clearComponentCache();
                                    }

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      sbindzau
                                      wrote on last edited by
                                      #28

                                      We have had a lot of problems with unexplained memory loss running 4.8.2 on Wince 6.0. Using 4.8.5 reduced the problem significantly.

                                      As we have lots of Loaders in qml we also started to call gc() explicity for every onSourceChanged: call. The gc() was hardly ever called, it seemed. I've heard that this has improved in Qt5, but we're not in a position to test this now.

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved