Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/selfish-moons-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"example-publish-wav": patch
"@livekit/rtc-node": patch
---

Fix memory leak of AudioSource
1 change: 1 addition & 0 deletions examples/publish-wav/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ while (written < dataSize) {
}
await source.waitForPlayout();
// release resources allocated for audio publishing
await track.close();
await source.close();

await room.disconnect();
Expand Down
4 changes: 4 additions & 0 deletions packages/livekit-rtc/src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export abstract class Track {
get muted(): boolean | undefined {
return this.info?.muted;
}

async close() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a optional boolean here to also close the source when closing the track? e.g.
async close(closeSource = true) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shubhrakanti @bcherry I'm not familiar with JS side but this sounds fair to me. What do you think?

I'm going to merge this pr but I'm open to implement this in a different pr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will create an other pr for it!

this.ffi_handle.dispose();
}
}

export class LocalAudioTrack extends Track {
Expand Down
Loading