Skip to content

Commit 980677d

Browse files
authored
[SYCL] Fix memory leak in program link (#6641)
This PR fixes the memory leak caused by missing the call to program release. Signed-off-by: Byoungro So <byoungro.so@intel.com>
1 parent dce0e70 commit 980677d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sycl/source/detail/program_impl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ void program_impl::link(std::string LinkOptions) {
295295
if (!LinkOpts) {
296296
LinkOpts = LinkOptions.c_str();
297297
}
298+
299+
// Plugin resets MProgram with a new pi_program as a result of the call to "piProgramLink".
300+
// Thus, we need to release MProgram before the call to piProgramLink.
301+
if (MProgram != nullptr)
302+
Plugin.call<PiApiKind::piProgramRelease>(MProgram);
303+
298304
RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piProgramLink>(
299305
MContext->getHandleRef(), Devices.size(), Devices.data(), LinkOpts,
300306
/*num_input_programs*/ 1, &MProgram, nullptr, nullptr, &MProgram);

0 commit comments

Comments
 (0)