summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Bull <irbull@eclipsesource.com>2024-02-10 02:53:28 -0800
committerGitHub <noreply@github.com>2024-02-10 12:53:28 +0200
commitf026f8120f97090d34a52b3dc023c82e0ede3f7d (patch)
treeb451139bb3d80868b5f5d3b32aba1cefcf499f39
parentcd9aea63b577a83def84dbd6dcd90a6fa02af745 (diff)
metal : use autoreleasepool to avoid memory leaks (#5437)
There appears to be a known memory leak when using the `MLTCommandBuffer`. It is suggested to use `@autoreleasepool` in [1,2] [1] https://developer.apple.com/forums/thread/662721 [2] https://forums.developer.apple.com/forums/thread/120931 This change-set wraps the `ggml_metal_graph_compute` in a `@autoreleasepool`. This commit addresses https://github.com/ggerganov/llama.cpp/issues/5436
-rw-r--r--ggml-metal.m2
1 files changed, 2 insertions, 0 deletions
diff --git a/ggml-metal.m b/ggml-metal.m
index 5260ed82..c1d8e2de 100644
--- a/ggml-metal.m
+++ b/ggml-metal.m
@@ -687,6 +687,7 @@ static bool ggml_metal_graph_compute(
struct ggml_metal_context * ctx,
struct ggml_cgraph * gf) {
+ @autoreleasepool {
MTLComputePassDescriptor * edesc = MTLComputePassDescriptor.computePassDescriptor;
edesc.dispatchType = MTLDispatchTypeSerial;
@@ -2272,6 +2273,7 @@ static bool ggml_metal_graph_compute(
[[MTLCaptureManager sharedCaptureManager] stopCapture];
}
+ }
return true;
}