From 7d2f0751d0043a4f5ac0c1a6118622202e4e9e47 Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Wed, 26 Jul 2023 22:21:15 +1000 Subject: macOS fix memory leak (hopefully) I think it's this simple, maybe I got confused by the memory going up a bit. But I think this actually works, simply releasing should ARC cleanup, and the memory goes up a bit just because of the NSCache but doens't go up further. Again it'd be nicer to use some different lower level way of playing, but this is definitely good enough for now. --- platform/darwin-native.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/darwin-native.m b/platform/darwin-native.m index 633d04b..07ca714 100644 --- a/platform/darwin-native.m +++ b/platform/darwin-native.m @@ -15,7 +15,6 @@ static NSCache *audio_cache = nil; @implementation ClakMacSound - (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)flag { [sound release]; - [sound dealloc]; } @end static ClakMacSound *clak_mac_sound = nil; @@ -52,6 +51,7 @@ void macos_sound_play(unsigned char *buffer, unsigned int buffer_len) } NSSound *sound = [[NSSound alloc] initWithData:buffer_ns]; + sound.delegate = clak_mac_sound; [sound play]; } -- cgit