Skip to content

Commit 1b09a02

Browse files
committed
Use @autoreleasepool to avoid memory leaks
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 #5436
1 parent 4b7b38b commit 1b09a02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ggml-metal.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,9 @@ GGML_CALL static ggml_backend_buffer_type_t ggml_backend_metal_get_default_buffe
25772577
GGML_CALL static bool ggml_backend_metal_graph_compute(ggml_backend_t backend, struct ggml_cgraph * cgraph) {
25782578
struct ggml_metal_context * metal_ctx = (struct ggml_metal_context *)backend->context;
25792579

2580-
return ggml_metal_graph_compute(metal_ctx, cgraph);
2580+
@autoreleasepool {
2581+
return ggml_metal_graph_compute(metal_ctx, cgraph);
2582+
}
25812583
}
25822584

25832585
GGML_CALL static bool ggml_backend_metal_supports_op(ggml_backend_t backend, const struct ggml_tensor * op) {

0 commit comments

Comments
 (0)