denden130
denden130

Reputation: 231

Cordova Media (Ionic App) - Playing Audio & Memory Leak

I discovered a memory leak issue when using Cordova Media plugin for my app. I tested on both Android and iOS devices. If you are wondering if I call the release method, yes I do release the audio after it completes playing or when it is no longer needed.

Whenever I create new media by using

var audio = new Media(src, successCallBack, errorCallBack)

it allocates approximately 20MB - 30 MB of memory on my devices. Once it completes playing the audio, I call the audio.release() method and I do see that the memory does get released after 10 - 15 seconds.

The problem occurs if I make consecutive audio play request to play next audio immediately after start playing the previous audio. The memory allocated by the previous audio does not get freed up immediately and it stacks with the next audio file's memory. If I continue this, the memory usage increases forever until the app stops due to memory allocation issue. I am not sure how to resolve the issue by myself.

I use cordova-plugin-media 1.0.1.

I welcome any advice. Thank you.

Upvotes: 1

Views: 519

Answers (1)

user3255670
user3255670

Reputation:

@denden130,
first I recall reading somewhere that release() does nothing. You are likely seeing the OS reclaim the memory. However, if they have fixed it, use it. However, I've looked into it. link to bug respositories. I see only one very old bug that is related. [Memory leak in media plugin].

Your other alternative is to use another audio plugin or use the HTML5 Audio API. Best of Luck.

Upvotes: 2

Related Questions