Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Force QML to release memory used by Audio (Android error -19)
Forum Update on Monday, May 27th 2025

Force QML to release memory used by Audio (Android error -19)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 623 Views
  • 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    I have an android app with approx 50 sound files. After playing approx 10 of these files it appears that Android runs out of memory, and I see this in the debug output:

    E libOpenSLES: Too many objects
    W libOpenSLES: Leaving Engine::CreateAudioPlay (SL_RESULTS_MEMORY_FAILURE)
    ...
    E MediaPLayerNative: error (1,-19)
    E MediaPlayer: error (1,-19)
    

    and this sound file will not play.

    From what I found online -19 means out of memory error. So right after each audio file plays I set source to "" based on suggestions on stackoverflow, but it did help (or at least not enough). I also reduced audio to low bitrate and single channel. But it's still not enough.

    I tried switching from Audio to Multimedia but it made no difference. I even went so far as to use a Loader to load the audio component, and unload it after the file played, and call gc() for garbage collection. Surprisingly, that made no difference either. For some reason QML is not freeing the memory used by audio files after they are played (and they are inside a QRC in this case).

    Help?! This seems like a pretty major issue - is there a workaround / fix? (using Qt 5.15.2)

    ocgltdO 1 Reply Last reply
    0
    • ocgltdO ocgltd

      I have an android app with approx 50 sound files. After playing approx 10 of these files it appears that Android runs out of memory, and I see this in the debug output:

      E libOpenSLES: Too many objects
      W libOpenSLES: Leaving Engine::CreateAudioPlay (SL_RESULTS_MEMORY_FAILURE)
      ...
      E MediaPLayerNative: error (1,-19)
      E MediaPlayer: error (1,-19)
      

      and this sound file will not play.

      From what I found online -19 means out of memory error. So right after each audio file plays I set source to "" based on suggestions on stackoverflow, but it did help (or at least not enough). I also reduced audio to low bitrate and single channel. But it's still not enough.

      I tried switching from Audio to Multimedia but it made no difference. I even went so far as to use a Loader to load the audio component, and unload it after the file played, and call gc() for garbage collection. Surprisingly, that made no difference either. For some reason QML is not freeing the memory used by audio files after they are played (and they are inside a QRC in this case).

      Help?! This seems like a pretty major issue - is there a workaround / fix? (using Qt 5.15.2)

      ocgltdO Offline
      ocgltdO Offline
      ocgltd
      wrote on last edited by
      #2

      @ocgltd
      Well I solved it - for anyone else experiencing this here is the solution. It (appears) that QML will not release audio players, so every one you create is held forever.

      The solution is to create a single audio player, in a singleton, and then use that to play (non-overlapping) audio files; changing the source each time.

      1 Reply Last reply
      1

      • Login

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