QProgressBar high memory usage



  • 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_()
    @



  • 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



  • 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.



  • 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?



  • 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.



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.