Skip to content

Commit e1a0780

Browse files
authored
Fix memory leak of AudioSource (#486)
* add close method to track * fix example as well * Create selfish-moons-tie.md
1 parent a6ebd81 commit e1a0780

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

.changeset/selfish-moons-tie.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"example-publish-wav": patch
3+
"@livekit/rtc-node": patch
4+
---
5+
6+
Fix memory leak of AudioSource

examples/publish-wav/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ while (written < dataSize) {
6464
}
6565
await source.waitForPlayout();
6666
// release resources allocated for audio publishing
67+
await track.close();
6768
await source.close();
6869

6970
await room.disconnect();

packages/livekit-rtc/src/track.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export abstract class Track {
4545
get muted(): boolean | undefined {
4646
return this.info?.muted;
4747
}
48+
49+
async close() {
50+
this.ffi_handle.dispose();
51+
}
4852
}
4953

5054
export class LocalAudioTrack extends Track {

0 commit comments

Comments
 (0)