Memory leak reported for long string debug variables in ULTs

This commit eliminates ULTs memory leaks reported for string debug variables
exceeding small string optimization size by calling shrink_to_fit() method
on string debug variables in DebugManagerStateRestore destructor.

Change-Id: I304c5c5c23c80f01fdf13f38cea5b4eceb18a94f
Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
Pawel Wilma
2018-11-23 09:43:06 +01:00
committed by sys_ocldev
parent 4f28f7a647
commit 86ecd1a4b8
3 changed files with 33 additions and 28 deletions

View File

@@ -10,6 +10,7 @@
#include "gmock/gmock.h"
#include "runtime/helpers/file_io.h"
#include "runtime/helpers/string_helpers.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/utilities/directory.h"
#include "unit_tests/mocks/mock_kernel.h"
@@ -941,3 +942,8 @@ TEST(DebugSettingsManager, givenTwoPossibleVariantsOfHardwareInfoOverrideStringT
debugManager.getHardwareInfoOverride(hwInfoConfig);
EXPECT_EQ(str1, hwInfoConfig);
}
TEST(DebugSettingsManager, givenStringDebugVariableWhenLongValueExeedingSmallStringOptimizationIsAssignedThenMemoryLeakIsNotReported) {
DebugManagerStateRestore debugManagerStateRestore;
DebugManager.flags.AUBDumpCaptureFileName.set("ThisIsVeryLongStringValueThatExceedSizeSpecifiedBySmallStringOptimizationAndCausesInternalStringBufferResize");
}