swift - IOS Memory Leak From AVFAudio - AVAudioSession -


i try create simple project. in project there images , names , when user push on image, image name played mp3 source file , pass next image. when pass next image, memory usage increasing 300mb fro each next item. when check memory leaks occur helping instruments,i saw of memory leak caused avfaudio library - avaudiosession.

enter image description here

maybe approach wrong play sound. here code play sound:

var sound: avaudioplayer!   func playsound(name: string) {          let path = bundle.main.path(forresource: name, oftype: "mp3")         let soundurl = url(fileurlwithpath: path!)         {             try sound = avaudioplayer(contentsof: soundurl)         } catch let err nserror {             print(err.debugdescription)         }     }   @ibaction func btnclick(_ sender: uibutton) {         playsound(name: "table")         sound.play()      } 

is "playing sound" way wrong? why memory leak happen? how solve problem. thank you

i tested on device , memory usage on device around 30-40mb. problem related testing on simulator. don't know why simulator not release avaudiosessions , increase memory usage.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -