]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
coreml : wrap inference call in @autoreleasepool to fix memory leak (#1218)
authorDener Stassun <redacted>
Tue, 29 Aug 2023 12:44:38 +0000 (09:44 -0300)
committerGitHub <redacted>
Tue, 29 Aug 2023 12:44:38 +0000 (15:44 +0300)
coreml/whisper-encoder.mm

index 09e44fcbf890fc0fd4828bb04fcbc25ce4abb84a..6cd90edfb19efbb79540150eefdeeca603f9f215 100644 (file)
@@ -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