diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp index f4e656413e..2dc6337196 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp @@ -2915,6 +2915,17 @@ VirtualGPU::releaseMemObjects() if (numGrpCb_ != NULL) { setConstantBuffer(SC_INFO_CONSTANTBUFFER, NULL, 0, 0); } + + if ((dev().scratch(hwRing()) != NULL) && + (dev().scratch(hwRing())->regNum_ > 0)) { + // Unbind scratch memory + const std::vector& mems = dev().scratch(hwRing())->memObjs_; + for (uint i = 0; i < mems.size(); ++i) { + if (mems[i] != NULL) { + setScratchBuffer(NULL, i); + } + } + } gpuEvents_.clear(); }