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. Memory not released when multiple Image is loaded continuously
Forum Update on Tuesday, May 27th 2025

Memory not released when multiple Image is loaded continuously

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
29 Posts 7 Posters 2.9k Views 5 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 Axel Spoerl
    22 Jul 2024, 09:36

    One step back again: What's the problem? The cache should resize, if the application runs out of memory. Does your application crash?

    A Offline
    A Offline
    AdarshKale
    wrote on 22 Jul 2024, 09:43 last edited by AdarshKale
    #13

    @Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:
    **The cache should resize

    I don't see the cache getting resized.
    if I run the top command and perform a script to continuously run the angle change,
    I get the memory utilized increased - leading to low memory, once the memory reaches below 15MB or so, the System Hangs, and after few seconds application crashes.

    Even if we come out of that screen during the update, the memory utilisation stops and is never freed.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Axel Spoerl
      Moderators
      wrote on 22 Jul 2024, 10:34 last edited by
      #14

      Which Qt version are you using?

      Software Engineer
      The Qt Company, Oslo

      A 1 Reply Last reply 22 Jul 2024, 11:25
      0
      • A Axel Spoerl
        22 Jul 2024, 10:34

        Which Qt version are you using?

        A Offline
        A Offline
        AdarshKale
        wrote on 22 Jul 2024, 11:25 last edited by
        #15

        @Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:

        Which Qt version are you using?

        5.15

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Axel Spoerl
          Moderators
          wrote on 22 Jul 2024, 11:39 last edited by
          #16

          That explains a lot. Outdated version. There is a memory leak in the quick pixmap cache, and it won't be fixed.
          Upgrade to Qt 6.7.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          1
          • A Offline
            A Offline
            AdarshKale
            wrote on 22 Jul 2024, 12:05 last edited by AdarshKale
            #17

            However, we cannot upgrade to newer Qt versions at this stage of the project.
            Is there any other way possible?

            There should be some workaround to clear the accumulated memory.?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Axel Spoerl
              Moderators
              wrote on 22 Jul 2024, 15:22 last edited by Axel Spoerl
              #18

              Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.
              There is no other way possible and a workaround for 5.15 will not be implemented.

              Software Engineer
              The Qt Company, Oslo

              G 1 Reply Last reply 23 Jul 2024, 20:16
              0
              • A Offline
                A Offline
                AdarshKale
                wrote on 23 Jul 2024, 08:30 last edited by AdarshKale
                #19

                There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
                hence we are finding an alternative way.

                Any possibility of calling garbage collection periodically?
                Will this accumulated memory get freed with garbage collection?

                J A 2 Replies Last reply 23 Jul 2024, 09:12
                0
                • A AdarshKale
                  23 Jul 2024, 08:30

                  There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
                  hence we are finding an alternative way.

                  Any possibility of calling garbage collection periodically?
                  Will this accumulated memory get freed with garbage collection?

                  J Online
                  J Online
                  JonB
                  wrote on 23 Jul 2024, 09:12 last edited by
                  #20

                  @AdarshKale said in Memory not released when multiple Image is loaded continuously:

                  Any possibility of calling garbage collection periodically?
                  Will this accumulated memory get freed with garbage collection?

                  No. No.

                  If you read referenced QTBUG you would see how involved the code is, and that it has been integrated into Qt6.x.

                  1 Reply Last reply
                  1
                  • A AdarshKale
                    23 Jul 2024, 08:30

                    There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
                    hence we are finding an alternative way.

                    Any possibility of calling garbage collection periodically?
                    Will this accumulated memory get freed with garbage collection?

                    A Offline
                    A Offline
                    Axel Spoerl
                    Moderators
                    wrote on 23 Jul 2024, 17:21 last edited by
                    #21

                    @AdarshKale

                    There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.

                    How complex and risky can an opensource wheel rotation app be, when it has to fit into 500MB of RAM including OS and Qt?

                    hence we are finding an alternative way.

                    No matter how often you ask: Upgrade to Qt6 is the only option.

                    Software Engineer
                    The Qt Company, Oslo

                    A 1 Reply Last reply 25 Jul 2024, 05:47
                    0
                    • A Axel Spoerl
                      22 Jul 2024, 15:22

                      Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.
                      There is no other way possible and a workaround for 5.15 will not be implemented.

                      G Offline
                      G Offline
                      GrecKo
                      Qt Champions 2018
                      wrote on 23 Jul 2024, 20:16 last edited by
                      #22

                      @Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:

                      Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.

                      You've got to chill. Qt 5.15 is still a supported LTS version. Doing a major version upgrade of a big depency like Qt is not a small meaningless task. It's very understandable that this can't been done in an advanced stage of a project.

                      @AdarshKale as it seems there is no easy fix for your issue in Qt 5, a workaround would be to not use Image. What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
                      Alternatively if you do need to have multiple images, you could try implementing a custom QQuickPaintedItem and painting your images there, bypassing the QtQuick cache.

                      A A 2 Replies Last reply 24 Jul 2024, 08:18
                      3
                      • J Offline
                        J Offline
                        jeremy_k
                        wrote on 23 Jul 2024, 22:05 last edited by
                        #23

                        Has precreating all of the required Image instances been tried?

                        I haven't delved into the pixmap cache bug, but the description suggests that it is loading (and unloading) that causes the leak, rather than repeat references to loaded data. Rather than changing the source of a single Image, just set the current image.visible to false, and the next to true.

                        Another alternative is to attempt to structure the animation as a transformation of a single Image.

                        Asking a question about code? http://eel.is/iso-c++/testcase/

                        1 Reply Last reply
                        1
                        • G GrecKo
                          23 Jul 2024, 20:16

                          @Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:

                          Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.

                          You've got to chill. Qt 5.15 is still a supported LTS version. Doing a major version upgrade of a big depency like Qt is not a small meaningless task. It's very understandable that this can't been done in an advanced stage of a project.

                          @AdarshKale as it seems there is no easy fix for your issue in Qt 5, a workaround would be to not use Image. What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
                          Alternatively if you do need to have multiple images, you could try implementing a custom QQuickPaintedItem and painting your images there, bypassing the QtQuick cache.

                          A Offline
                          A Offline
                          Axel Spoerl
                          Moderators
                          wrote on 24 Jul 2024, 08:18 last edited by
                          #24

                          @GrecKo
                          I'll chill, thanks for the feedback!
                          5.15 releases are either outdated, or commercial.
                          Hence my reluctance to supporting them through the forum.

                          Software Engineer
                          The Qt Company, Oslo

                          1 Reply Last reply
                          0
                          • A Axel Spoerl
                            23 Jul 2024, 17:21

                            @AdarshKale

                            There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.

                            How complex and risky can an opensource wheel rotation app be, when it has to fit into 500MB of RAM including OS and Qt?

                            hence we are finding an alternative way.

                            No matter how often you ask: Upgrade to Qt6 is the only option.

                            A Offline
                            A Offline
                            AdarshKale
                            wrote on 25 Jul 2024, 05:47 last edited by AdarshKale
                            #25

                            @Axel-Spoerl

                            How complex and risky can an opensource wheel rotation app

                            Wheel Rotation is just one feature among 100s of them in this project.
                            We will consider upgrading to the latest Qt versions going further in upcoming projects.

                            1 Reply Last reply
                            0
                            • G GrecKo
                              23 Jul 2024, 20:16

                              @Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:

                              Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.

                              You've got to chill. Qt 5.15 is still a supported LTS version. Doing a major version upgrade of a big depency like Qt is not a small meaningless task. It's very understandable that this can't been done in an advanced stage of a project.

                              @AdarshKale as it seems there is no easy fix for your issue in Qt 5, a workaround would be to not use Image. What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
                              Alternatively if you do need to have multiple images, you could try implementing a custom QQuickPaintedItem and painting your images there, bypassing the QtQuick cache.

                              A Offline
                              A Offline
                              AdarshKale
                              wrote on 25 Jul 2024, 06:01 last edited by AdarshKale
                              #26

                              @GrecKo

                              What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.

                              Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.
                              We will try on the QQuickPaintedItem, Thanks for the input.

                              G 1 Reply Last reply 25 Jul 2024, 08:29
                              0
                              • A AdarshKale
                                25 Jul 2024, 06:01

                                @GrecKo

                                What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.

                                Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.
                                We will try on the QQuickPaintedItem, Thanks for the input.

                                G Offline
                                G Offline
                                GrecKo
                                Qt Champions 2018
                                wrote on 25 Jul 2024, 08:29 last edited by
                                #27

                                @AdarshKale said in Memory not released when multiple Image is loaded continuously:

                                Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.

                                I don't see how that invalidate using a simple rotation. But I don't have all the info you have so it might actually be not possible. Are you willing to share an image of how the wheels will appear rotated? Even a quick sketch should do.

                                A 1 Reply Last reply 26 Jul 2024, 05:50
                                0
                                • G GrecKo
                                  25 Jul 2024, 08:29

                                  @AdarshKale said in Memory not released when multiple Image is loaded continuously:

                                  Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.

                                  I don't see how that invalidate using a simple rotation. But I don't have all the info you have so it might actually be not possible. Are you willing to share an image of how the wheels will appear rotated? Even a quick sketch should do.

                                  A Offline
                                  A Offline
                                  AdarshKale
                                  wrote on 26 Jul 2024, 05:50 last edited by AdarshKale
                                  #28

                                  @GrecKo said in Memory not released when multiple Image is loaded continuously:

                                  I don't see how that invalidate using a simple rotation. But I don't have all the info you have so it might actually be not possible. Are you willing to share an image of how the wheels will appear rotated? Even a quick sketch should do.

                                  f5a6b131-f279-4d2e-aab7-4f29eda21bab-image.png

                                  From centre to right, we have around 25 images and from centre to left, we have 25 images.
                                  We have intermediate angles between the centre and right as well as left.

                                  We need to rotate the wheels based on the Actual steering wheel angle.
                                  The wheels are also not like the 2D circular image, they have different perspectives when they are at different angles.

                                  G 1 Reply Last reply 26 Jul 2024, 15:20
                                  0
                                  • A AdarshKale
                                    26 Jul 2024, 05:50

                                    @GrecKo said in Memory not released when multiple Image is loaded continuously:

                                    I don't see how that invalidate using a simple rotation. But I don't have all the info you have so it might actually be not possible. Are you willing to share an image of how the wheels will appear rotated? Even a quick sketch should do.

                                    f5a6b131-f279-4d2e-aab7-4f29eda21bab-image.png

                                    From centre to right, we have around 25 images and from centre to left, we have 25 images.
                                    We have intermediate angles between the centre and right as well as left.

                                    We need to rotate the wheels based on the Actual steering wheel angle.
                                    The wheels are also not like the 2D circular image, they have different perspectives when they are at different angles.

                                    G Offline
                                    G Offline
                                    GrecKo
                                    Qt Champions 2018
                                    wrote on 26 Jul 2024, 15:20 last edited by
                                    #29

                                    I'd try doing that with an AnimatedSprite, you can set the currentFrame property manually.

                                    1 Reply Last reply
                                    0

                                    22/29

                                    23 Jul 2024, 20:16

                                    • Login

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