Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProgressBar high memory usage
Forum Updated to NodeBB v4.3 + New Features

QProgressBar high memory usage

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.1k Views 1 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.
  • T Offline
    T Offline
    Tarmack
    wrote on last edited by
    #1

    I have a program with a progress bar. It is used to signify the amount of a song played. This progress bar is used again for each song. When the program has been sitting for a few songs the progress bar uses quite a lot of memory.

    I've written a little test application in both Python (my program is in python (PyQT)) and in C++. In both casses a fairly wide (800-1000px) progress bar running to completion uses about 50MB ram. That seems a bit exessive to me.

    I'm guessing QrogressBar caches something. Can anyone help me find what can be done about the high memory usage?

    This is the Python code I use. This shows exactly the same symptoms as a C++ implementation (but uses less code:)).
    @
    #!/bin/env python

    from PyQt4 import QtGui
    from PyQt4 import QtCore
    import sys
    import time

    app = QtGui.QApplication(sys.argv)

    window = QtGui.QWidget()
    progress = QtGui.QProgressBar(window)
    progress.setMaximum(100)
    layout = QtGui.QVBoxLayout()
    layout.addWidget(progress)
    window.setLayout(layout)

    def update():
    if progress.value() == progress.maximum():
    progress.reset()
    progress.setMaximum(progress.maximum() + 20)
    progress.setValue(progress.value() + 1)

    timer = QtCore.QTimer(window)
    timer.start(100)
    timer.connect(timer, QtCore.SIGNAL('timeout()'), update)

    window.show()
    time.sleep(8)
    app.exec_()
    @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      l.v.p
      wrote on last edited by
      #2

      Maybe I'm wrong, but when ProgressBar reaches maximum, you reset it and then add + 20 to the maximum. So after all, new maximum for PB is 120. Again, after next song, new max will be 140?!

      And one thing is concerning me: how do you looked up the QProgressBar usage

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tarmack
        wrote on last edited by
        #3

        Thanks for your reply. I used htop to look up the memory usage. So it's not only the progress bar's memory usage ofcourse. But you can see the data and res segments rise rapidly.

        The test program does indeed grow the maximum. I did this to simulate the changing maximum in my program. It makes little difference on the memory usage actually. It seems that the more steps are taken, the more memory is used.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          l.v.p
          wrote on last edited by
          #4

          bq. It seems that the more steps are taken, the more memory is used.

          Which is quite obvious when you loading only into memory, without deleting items.
          And I hardly believe that QProgressBar is using so much memory. Check out your code, maybe it's something with memory managment when you operating with audio files?

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tarmack
            wrote on last edited by
            #5

            No, this test program will use so much memory. Nothing more than a window with a progress bar. The code above is not from the sound program. It is just to show the symptoms.

            I too can hardly believe that QProgressBar is using all this memory but the test program indicates it does.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              l.v.p
              wrote on last edited by
              #6

              So I don't have any ideas what can be wrong.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Tarmack
                wrote on last edited by
                #7

                Me neither, hence the forum post. I thank you for your help anyway.

                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