Playsound() Memory Leak?

Post bugreports for the Mac OSX version here
collectordave
Addict
Addict
Posts: 1275
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Playsound() Memory Leak?

Post by collectordave »

MAC OS Mojave 10.14.6

PB 5.73 LTS 64bit

My app that uses PlaySound() started to slow down my computer after playing a good few tracks so investigated little.

Started Activity monitor and checked memory.

Using the following code (Replace track with one of your own)

Code: Select all

InitSound()           ; Initialize Sound system
UseOGGSoundDecoder()

Global Window_0

Global btnPlay, btnStop,CurrentSound

  Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
  btnPlay = ButtonGadget(#PB_Any, 110, 110, 70, 30, "Play")
  btnStop = ButtonGadget(#PB_Any, 250, 110, 70, 30, "Stop")

  Repeat
   
Event = WaitWindowEvent()
  Select event
    Case #PB_Event_CloseWindow
      End



    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case btnPLay
          
          CurrentSound = LoadSound(#PB_Any,GetUserDirectory(#PB_Directory_Documents) +"TI Media/5000 Volts/5000 Volts - I'm On Fire.ogg")
  
          PlaySound(CurrentSound)
          
        Case btnStop

          FreeSound(#PB_All)

      EndSelect
  EndSelect

      
Until Event = #PB_Event_CloseWindow

End
Playing the track increases the amount of memory used as I expected.

Stoping the track by using freesound(#PB_All) appears not to release the memory.

The more times you play the track and stop it the more memory is used.

I thought Freesound() released the memory back to the system?

Puzzled.

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.