Add missing cleanup of private scratch allocation

Related-To: NEO-3190

Change-Id: I7b327c76cf62fab50d11ad06dcc067e92c650815
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2019-06-28 12:42:32 +02:00
committed by sys_ocldev
parent 27f3f8ea8f
commit 91858d89d8
2 changed files with 18 additions and 0 deletions

View File

@ -25,6 +25,9 @@ ScratchSpaceController::~ScratchSpaceController() {
if (scratchAllocation) {
getMemoryManager()->freeGraphicsMemory(scratchAllocation);
}
if (privateScratchAllocation) {
getMemoryManager()->freeGraphicsMemory(privateScratchAllocation);
}
}
MemoryManager *ScratchSpaceController::getMemoryManager() const {

View File

@ -13,6 +13,7 @@
#include "runtime/command_stream/linear_stream.h"
#include "runtime/command_stream/preemption.h"
#include "runtime/command_stream/scratch_space_controller.h"
#include "runtime/command_stream/scratch_space_controller_base.h"
#include "runtime/event/user_event.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/blit_commands_helper.h"
@ -723,3 +724,17 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
}
}
}
struct MockScratchSpaceController : ScratchSpaceControllerBase {
using ScratchSpaceControllerBase::privateScratchAllocation;
using ScratchSpaceControllerBase::ScratchSpaceControllerBase;
};
using ScratchSpaceControllerTest = Test<DeviceFixture>;
TEST_F(ScratchSpaceControllerTest, whenScratchSpaceControllerIsDestroyedThenItReleasePrivateScratchSpaceAllocation) {
MockScratchSpaceController scratchSpaceController(*pDevice->getExecutionEnvironment(), *pDevice->getCommandStreamReceiver().getInternalAllocationStorage());
scratchSpaceController.privateScratchAllocation = pDevice->getExecutionEnvironment()->memoryManager->allocateGraphicsMemoryInPreferredPool(MockAllocationProperties{MemoryConstants::pageSize}, nullptr);
EXPECT_NE(nullptr, scratchSpaceController.privateScratchAllocation);
//no memory leak is expected
}