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. [SOLVED] QAudioProbe in Windows is using too much memory
Qt 6.11 is out! See what's new in the release blog

[SOLVED] QAudioProbe in Windows is using too much memory

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 4.9k 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.
  • O Offline
    O Offline
    oh3netid
    wrote on last edited by
    #1

    Hello,

    In Windows, whenever I attach an audio probe to a QMediaPlayer my memory usage (as reported in Task Manager) starts to look like a stopwatch (ever increasing). Here is a simple example that shows what I mean.

    @
    QMediaPlayer *playerA = new QMediaPlayer(this);
    playerA->setMedia(QUrl_to_my.mp3);

    QAudioProbe *probe = new QAudioProbe(this);
    probe->setSource(playerA);
    
    playerA->play();
    

    @

    When executed, the app continuously consumes memory unless I comment out the probe. I noticed in the AudioRecorder example that the memory usage remains stable. Also, the above doesn't have excess memory consumption when run in OSX. Could this be a bug with the Windows implementation of QAudioProbe when set to a QMediaPlayer source?

    After 3 hours, the memory usage is so bad that my app crashes. Is there anyway to force the probe to free up the memory? I have already tried deleteLater and delete, then recreating the probe but that didn't do anything. Can anyone suggest any alternatives or workarounds?

    Thanks,
    -Will

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      That sounds like a memory leak bug in the Windows implementation (which means you can't reclaim the memory, unfortunately). Please report it to https://bugreports.qt-project.org/ and attach a minimal, compilable example. There's a good chance to get it fixed in time for Qt 5.3 (which is scheduled to be released in April)

      But anyway, how do you extract the data from the QAudioProbe?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • O Offline
        O Offline
        oh3netid
        wrote on last edited by
        #3

        Thanks for the quick response!
        I just filed the bug report as you suggested.

        In answer to your question, I connect to the audioBufferProbed signal. That part all works so I left it out of the example.

        Any ideas for a workaround?

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          Can you post the link to your report here, so that others can watch the issue too?

          I'm not aware of any workarounds for this, I'm afraid. If there is a memory leak inside the QAudioProbe code, then there's not much we can do in "external" code, except avoid using QAudioProbe.

          What are you using the audio probe for?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • O Offline
            O Offline
            oh3netid
            wrote on last edited by
            #5

            "Link to bug report":https://bugreports.qt-project.org/browse/QTBUG-36670

            Basically, I was using the probe to detect when to crossfade into the next song (since a lot of songs end with periods of silence). Everything was working great except for the memory leak.

            After your comment about avoiding the probe, I thought about using QAudioDecoder to pre-calculate all my fade out times. Then I discovered that, not only did it result in the same memory leak, but it also doesn't work under OSX (audio decode not implemented!).

            Oy vey.

            I don't suppose I could reclaim the memory by moving the audio decoder code into a QThread and then destroying the thread when I get my result. Overly wishful thinking?

            1 Reply Last reply
            0
            • O Offline
              O Offline
              oh3netid
              wrote on last edited by
              #6

              I don’t suppose I could reclaim the memory by moving the audio decoder code into a QThread and then destroying the thread when I get my result.

              And the answer turns out to be no. Out of tricks again. Bleh. Guess I just have to seek a solution outside of Qt.

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                What happens if there is a period of silence in the middle of the track?

                Would it be acceptable for now to calculated crossfade time based on mediaPlayer->duration() ? (until the bug is fixed)

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

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

                  [quote author="oh3netid" date="1391673014"]I don't suppose I could reclaim the memory by moving the audio decoder code into a QThread and then destroying the thread when I get my result. Overly wishful thinking?[/quote]

                  No, but the same trick in a separate process might work. Not pretty (in fact: quite hacky), but memory leaks in libs you don't control sometimes require desperate measures.

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    oh3netid
                    wrote on last edited by
                    #9

                    [quote author="JKSH" date="1391681951"]What happens if there is a period of silence in the middle of the track?

                    Would it be acceptable for now to calculated crossfade time based on mediaPlayer->duration() ? (until the bug is fixed)[/quote]

                    I only start checking for silence towards the end of the track (last 5 seconds or so). Unfortunately, songs vary in how much silence they tack on the end. The audio probe was perfect for the job. I think I'm going to have to poke around inside the library (we are approaching desperate measures time). Thanks for all the advice.

                    1 Reply Last reply
                    0
                    • O Offline
                      O Offline
                      oh3netid
                      wrote on last edited by
                      #10

                      [quote author="Andre" date="1391682865"]
                      No, but the same trick in a separate process might work. Not pretty (in fact: quite hacky), but memory leaks in libs you don't control sometimes require desperate measures.
                      [/quote]

                      Thanks for the suggestion. I think I'll try to debug the library before I go the worker process route. In the long run, seems like it would be the same amount of work :)

                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        oh3netid
                        wrote on last edited by
                        #11

                        Afterward: In the end, I created a helper app that calculates where in an audio track to fade out at before exiting. The leaked memory is indeed reclaimed on app exit. Any time I play a new track I launch the helper app with QProcess and receive the fadeout time with QTcpSocket. Actually not a very bad solution at all and very easy to revert once the memory leak is taken care of.

                        Fin!

                        1 Reply Last reply
                        0
                        • JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote on last edited by
                          #12

                          A workaround worthy of http://thedailywtf.com/ ! :-D It's not your fault though.

                          Anyway, I'm glad to hear you've found a solution. Could you please edit your original post and add "[SOLVED]" to your title?

                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                          1 Reply Last reply
                          0
                          • O Offline
                            O Offline
                            oh3netid
                            wrote on last edited by
                            #13

                            Done! Thanks.

                            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