question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DeviceController audio memory leak

See original GitHub issue

What happened and what did you expect to happen?

I was profiling a simple React component that only imports the chime JS sdk. It simply creates a new DefaultDeviceController when mounted, and calls the .destroy() method on unmount.

It seems that AudioBufferSourceNode persists and a new one is created every time the component is mounted.

This was discovered using heap snapshots in Chrome.

Heap snapshot of initially unmounted component that is mounted and unmounted, repeated twice (Unmounted, Mounted, Unmounted, Mounted, Unmounted): heap

Have you reviewed our existing documentation?

Reproduction steps

  1. Create a new DefaultDeviceController
  2. Call .destroy() on the created instance
  3. Create a new instance of DefaultDeviceController again
  4. Memory leak is observed with an additional AudioBufferSourceNode

Amazon Chime SDK for JavaScript version

2.17.0

What browsers are you seeing the problem on?

Chrome

Browser version

94.0.4606.71

Meeting and Attendee ID Information.

No response

Browser console logs

N/A

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
emopti-jrufercommented, Feb 7, 2022

I am running into the same issue. I am not using using the React components but rather using the SDK in an Angular app. What I discovered when trying to figure out why the memory in our app was increasing after every meeting is that the “AudioBufferSourceNode” objects were being created during the teardown of the meeting. Initially followed the convention used in the examples for tearing down by calling MeetingSession.audioVideo.chooseXXXDevice(null). The chooseAudioInputDevice(null) is creating a the empty audio device. Next tried calling MeetingSession.destroy(), which is not documented anywhere, instead of calling chooseAudioInputDevice(null). This resulted in the same behavior because it is doing the same thing.

Overall there needs to be a short circuit when calling chooseAudioInputDevice(null) during destroy so it does not create new resources that are never cleaned up. The following reference is what is creating the empty device during destroy.

https://github.com/aws/amazon-chime-sdk-js/blob/17a5fc7163cf020deeaa90ff45ee414188504862/src/devicecontroller/DefaultDeviceController.ts#L1465

0reactions
xuesichaocommented, Feb 9, 2022

@emopti-jrufer Hi, thanks for providing such a detailed observation. We are working on a fix now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Audio memory leak - Microsoft Community
I have windows 10 and about a couple weeks ago out of the blue, my audio is using an absurd amount of ram...
Read more >
DeviceController | amazon-chime-sdk-js
... you should perform some cleanup steps in order to avoid memory leaks: Call DeviceController.destroy to stop all active audio and video inputs....
Read more >
web audio memory leak #5224 - photonstorm/phaser - GitHub
I've checked and see massive memory leak. I made small test as a demo with 1mb audio file to show the problem quickly...
Read more >
Xcode Audio Memory Leak? - Stack Overflow
I'm working on a soundboard app, and when I analyze my app, it always detects memory leaks. It works fine on the iOS...
Read more >
DeviceController audio memory leak - Aws/Amazon-Chime ...
DeviceController audio memory leak ... This issue has been created since 2021-10-08. What happened and what did you expect to happen? I was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found