Skip to content

Commit 2b3c77d

Browse files
irbulljordankanter
authored andcommitted
metal : use autoreleasepool to avoid memory leaks (ggml-org#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 ggml-org#5436
1 parent b84891a commit 2b3c77d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ggml-metal.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ static bool ggml_metal_graph_compute(
687687
struct ggml_metal_context * ctx,
688688
struct ggml_cgraph * gf) {
689689

690+
@autoreleasepool {
690691
MTLComputePassDescriptor * edesc = MTLComputePassDescriptor.computePassDescriptor;
691692
edesc.dispatchType = MTLDispatchTypeSerial;
692693

@@ -2272,6 +2273,7 @@ static bool ggml_metal_graph_compute(
22722273
[[MTLCaptureManager sharedCaptureManager] stopCapture];
22732274
}
22742275

2276+
}
22752277
return true;
22762278
}
22772279

0 commit comments

Comments
 (0)