Skip to content

Commit 6acb812

Browse files
author
Alexander Batashev
authored
[SYCL] Fix memory leak in L0 plugin (#2110)
Signed-off-by: Alexander Batashev <[email protected]>
1 parent b00fb7c commit 6acb812

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sycl/plugins/level_zero/pi_level0.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
676676
// Confirm at least one memory is available in the device
677677
assert(ZeAvailMemCount > 0);
678678

679-
ze_device_memory_properties_t *ZeDeviceMemoryProperties;
679+
std::vector<ze_device_memory_properties_t> ZeDeviceMemoryProperties;
680680
try {
681-
ZeDeviceMemoryProperties =
682-
new ze_device_memory_properties_t[ZeAvailMemCount]();
681+
ZeDeviceMemoryProperties.reserve(ZeAvailMemCount);
683682
} catch (const std::bad_alloc &) {
684683
return PI_OUT_OF_HOST_MEMORY;
685684
} catch (...) {
@@ -693,7 +692,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
693692
// TODO: cache various device properties in the PI device object,
694693
// and initialize them only upon they are first requested.
695694
ZE_CALL(zeDeviceGetMemoryProperties(ZeDevice, &ZeAvailMemCount,
696-
ZeDeviceMemoryProperties));
695+
ZeDeviceMemoryProperties.data()));
697696

698697
ze_device_image_properties_t ZeDeviceImageProperties;
699698
ZeDeviceImageProperties.version = ZE_DEVICE_IMAGE_PROPERTIES_VERSION_CURRENT;

0 commit comments

Comments
 (0)