mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-20 13:11:34 +08:00
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:

committed by
sys_ocldev

parent
27f3f8ea8f
commit
91858d89d8
@ -25,6 +25,9 @@ ScratchSpaceController::~ScratchSpaceController() {
|
||||
if (scratchAllocation) {
|
||||
getMemoryManager()->freeGraphicsMemory(scratchAllocation);
|
||||
}
|
||||
if (privateScratchAllocation) {
|
||||
getMemoryManager()->freeGraphicsMemory(privateScratchAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
MemoryManager *ScratchSpaceController::getMemoryManager() const {
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user