Spaces:
Sleeping
Sleeping
metal : use autoreleasepool to avoid memory leaks (llama/5437)
Browse filesThere 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
- ggml-metal.m +2 -0
ggml-metal.m
CHANGED
|
@@ -696,6 +696,7 @@ static bool ggml_metal_graph_compute(
|
|
| 696 |
struct ggml_metal_context * ctx,
|
| 697 |
struct ggml_cgraph * gf) {
|
| 698 |
|
|
|
|
| 699 |
MTLComputePassDescriptor * edesc = MTLComputePassDescriptor.computePassDescriptor;
|
| 700 |
edesc.dispatchType = MTLDispatchTypeSerial;
|
| 701 |
|
|
@@ -2281,6 +2282,7 @@ static bool ggml_metal_graph_compute(
|
|
| 2281 |
[[MTLCaptureManager sharedCaptureManager] stopCapture];
|
| 2282 |
}
|
| 2283 |
|
|
|
|
| 2284 |
return true;
|
| 2285 |
}
|
| 2286 |
|
|
|
|
| 696 |
struct ggml_metal_context * ctx,
|
| 697 |
struct ggml_cgraph * gf) {
|
| 698 |
|
| 699 |
+
@autoreleasepool {
|
| 700 |
MTLComputePassDescriptor * edesc = MTLComputePassDescriptor.computePassDescriptor;
|
| 701 |
edesc.dispatchType = MTLDispatchTypeSerial;
|
| 702 |
|
|
|
|
| 2282 |
[[MTLCaptureManager sharedCaptureManager] stopCapture];
|
| 2283 |
}
|
| 2284 |
|
| 2285 |
+
}
|
| 2286 |
return true;
|
| 2287 |
}
|
| 2288 |
|