Closed stefanospapa closed 2 years ago
Unfortunately this is a known issue, and I've been trying to find a way around this but with no luck so far.
Keep in mind that the memory is released once the podcast stops playing, do not trust the Xcode's memory graph on the left pane. If you Profile the app, use the Instruments app to check the memory, you will see that while the memory does increase it goes away after you stopped the audio or play another audio file.
Some more context:
RemoteAudioSource
uses OperationQueue
to "store" the audio packets and sends those when requested by the player. This causes the memory to increase since it temporary stores those data in memory. I tried multiple things to try and resolve this but it was always the same outcome.
The original library uses the deprecated (since iOS 9!) CFReadStreamCreateForHTTPRequest which doesn't have this issue but there's hasn't been a direct replacement for this API.
Observing the allocations in the instruments app we do not see any releases. Memory is increasing constantly even if we stop the podcast and play a radio stream. Do we monitor wrong data?
Our main concern is if this issue will prevent the app to successfully pass the Apple evaluation. Are there any other apps that use this library and manage to be on the Apple store?
@stefanospapa Hmm, it seems you're right.
Can you try out this branch and see if this fixes the leak issue? https://github.com/dimitris-c/AudioStreaming/tree/bug/remoteaudiosource-memory-leak-fix
If you could test this with your app, especially the seek functionality and report that everything is working as expected I would appreciate it and make a release.
PR #28 for this fix.
We tested your fix in the example application and in our application. It seems OK. Seek operation works normally.
You may proceed with the release. Thanks a lot for the support.
Release is out - https://github.com/dimitris-c/AudioStreaming/releases/tag/0.7.0
Thanks for identifying and QA'ing this issue
During some additional tests we spotted another sub issue of this problem. When we play a podcast like "Swift by Sundell" and pause the player, and then we play a radio station, memory is not released. We have to stop the podcast playing in order to let memory be released. Is there any way to "clear" the player before starting a new playing session? Or any other solution?
Oh that's a good catch — will make a PR a bit later @stefanospapa
This should be fixed now — Update version to 0.8.0 as well, let me know if this fixes the issue
Version 0.8.0 fixes the issue. Thanks for your support.
We noticed this issue on our application but also in the example in GitHub. Trying to play "Swift by Sundell" podcast and then again "Swift by Sundell" the memory used is constantly increasing. It seems that the allocated memory (200MB for this audio item) is not released. This behaviour does not affect live streaming audio like radio stations.