Skip to content

Commit 9e2ec8e

Browse files
committed
metal : fix more leaks
1 parent e778b10 commit 9e2ec8e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ggml-metal.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,15 +1177,11 @@ void ggml_metal_graph_compute(
11771177
// wait for all threads to finish
11781178
dispatch_barrier_sync(queue, ^{});
11791179

1180-
[command_buffers[n_cb - 1] waitUntilCompleted];
1181-
1182-
// release resources
1183-
[edesc release];
1184-
[queue release];
1185-
11861180
// check status of command buffers
11871181
// needed to detect if the device ran out-of-memory for example (#1881)
11881182
for (int i = 0; i < n_cb; i++) {
1183+
[command_buffers[i] waitUntilCompleted];
1184+
11891185
MTLCommandBufferStatus status = (MTLCommandBufferStatus) [command_buffers[i] status];
11901186
if (status != MTLCommandBufferStatusCompleted) {
11911187
fprintf(stderr, "%s: command buffer %d failed with status %lu\n", __func__, i, status);
@@ -1196,6 +1192,10 @@ void ggml_metal_graph_compute(
11961192
[command_buffers[i] release];
11971193
}
11981194

1195+
// release resources
1196+
[edesc release];
1197+
[queue release];
1198+
11991199
[command_encoders release];
12001200
[command_buffers release];
12011201
}

0 commit comments

Comments
 (0)