From: Dener Stassun Date: Tue, 29 Aug 2023 12:44:38 +0000 (-0300) Subject: coreml : wrap inference call in @autoreleasepool to fix memory leak (#1218) X-Git-Tag: upstream/1.7.4~1348 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=18e9889418f9b94635bb68c28168269cbad1d63e;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp coreml : wrap inference call in @autoreleasepool to fix memory leak (#1218) --- 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