Skip to content

Commit

Permalink
Fixes memory leak in MetalInfo::get_usable_devices()
Browse files Browse the repository at this point in the history
  • Loading branch information
deranen committed Sep 23, 2024
1 parent f4a8b37 commit 6598bb6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/device/metal/util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,19 @@
return usable_devices;
}

NSArray *devices = MTLCopyAllDevices();

/* If the system has both an AMD GPU (discrete) and an Intel one (integrated), prefer the AMD
* one. This can be overridden with CYCLES_METAL_FORCE_INTEL. */
bool has_usable_amd_gpu = false;
if (@available(macos 12.3, *)) {
for (id<MTLDevice> device in MTLCopyAllDevices()) {
for (id<MTLDevice> device in devices) {
has_usable_amd_gpu |= (get_device_vendor(device) == METAL_GPU_AMD);
}
}

metal_printf("Usable Metal devices:\n");
for (id<MTLDevice> device in MTLCopyAllDevices()) {
for (id<MTLDevice> device in devices) {
string device_name = get_device_name(device);
MetalGPUVendor vendor = get_device_vendor(device);
bool usable = false;
Expand Down Expand Up @@ -145,6 +147,8 @@
if (usable_devices.empty()) {
metal_printf(" No usable Metal devices found\n");
}

[devices release];
already_enumerated = true;

return usable_devices;
Expand Down

0 comments on commit 6598bb6

Please sign in to comment.