InitRenderTarget used a pure new to allocate VkImageObj, and that allocation never got deleted. Switch to std::unique_ptr as that allows us to delete a little bit more code while fixing this leak.
Note: Google Test filter = *Device*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from VkLayerTest
[ RUN ] VkLayerTest.UseObjectWithWrongDevice
[ OK ] VkLayerTest.UseObjectWithWrongDevice (2029 ms)
[----------] 1 test from VkLayerTest (2030 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (2030 ms total)
[ PASSED ] 1 test.
=================================================================
==9236==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 176 byte(s) in 1 object(s) allocated from:
#0 0x7f7936a9c340 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdb340)
#1 0x55b7958d939d in VkRenderFramework::InitRenderTarget(unsigned int, VkImageView_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/vkrenderframework.cpp:379
#2 0x55b7958d8a25 in VkRenderFramework::InitRenderTarget(unsigned int) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/vkrenderframework.cpp:342
#3 0x55b7958d89d7 in VkRenderFramework::InitRenderTarget() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/vkrenderframework.cpp:340
#4 0x55b7954949a7 in VkLayerTest_UseObjectWithWrongDevice_Test::TestBody() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/layer_validation_tests.cpp:2523
#5 0x7f79350a6beb in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2078
#6 0x7f7935094391 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2114
#7 0x7f7935037c53 in testing::Test::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2150
#8 0x7f7935039948 in testing::TestInfo::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2326
#9 0x7f793503af03 in testing::TestCase::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2444
#10 0x7f793505333d in testing::internal::UnitTestImpl::RunAllTests() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:4311
#11 0x7f79350ab3db in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2078
#12 0x7f7935097f07 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2114
#13 0x7f793504e4cf in testing::UnitTest::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:3922
#14 0x55b7957fee80 in RUN_ALL_TESTS() (/home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/tests/vk_layer_validation_tests+0x9dce80)
#15 0x55b7957d93e3 in main /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/layer_validation_tests.cpp:27913
#16 0x7f7933548a86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21a86)
SUMMARY: AddressSanitizer: 176 byte(s) leaked in 1 allocation(s).
InitRenderTarget
used a pure new to allocateVkImageObj
, and that allocation never got deleted. Switch tostd::unique_ptr
as that allows us to delete a little bit more code while fixing this leak.