From 18e9889418f9b94635bb68c28168269cbad1d63e Mon Sep 17 00:00:00 2001 From: Dener Stassun Date: Tue, 29 Aug 2023 09:44:38 -0300 Subject: [PATCH] coreml : wrap inference call in @autoreleasepool to fix memory leak (#1218) --- coreml/whisper-encoder.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/coreml/whisper-encoder.mm b/coreml/whisper-encoder.mm index 09e44fcb..6cd90edf 100644 --- a/coreml/whisper-encoder.mm +++ b/coreml/whisper-encoder.mm @@ -53,9 +53,11 @@ void whisper_coreml_encode( error: nil ]; - whisper_encoder_implOutput * outCoreML = [(__bridge id) ctx->data predictionFromLogmel_data:inMultiArray error:nil]; + @autoreleasepool { + whisper_encoder_implOutput * outCoreML = [(__bridge id) ctx->data predictionFromLogmel_data:inMultiArray error:nil]; - memcpy(out, outCoreML.output.dataPointer, outCoreML.output.count * sizeof(float)); + memcpy(out, outCoreML.output.dataPointer, outCoreML.output.count * sizeof(float)); + } } #if __cplusplus