Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix memory leak in test "VegProdConstructor"
- close #205 - remove leak suppression in "SW_VPD_construct" that is no longer needed - the test "VegProdStructTest.VegProdConstructor" (previously named, as of v7.0.0, "VegTest.Constructor") now (1) uses a local copy of SW_VEGPROD and (2) calls `SW_VPD_deconstruct()` to avoid a memory leak - Previously, the test used `SW_All.VegProd` or a global variable (for which `SW_VPD_construct()` has already been called once and allocated memory, e.g., during the test fixture's `SetUp()` or `Reset_SOILWAT2_after_UnitTest()`); then the (second) call to `SW_VPD_construct()` would allocate memory a second time (thus the memory previously allocated is leaked). However, the call to `SW_VPD_deconstruct()` (either in the test or during the test fixture's `TearDown()` or `Reset_SOILWAT2_after_UnitTest()`) will de-allocate only the most recently allocated memory (and, if called again, was seeing only NULL). - before this commit, I was getting with `MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocScribble=1 MallocPreScribble=1 MallocCheckHeapStart=0 MallocCheckHeapEach=0 leaks -quiet -atExit -- bin/sw_test` > 7 leaks for 896 total leaked bytes. 7 (896 bytes) << TOTAL >> 1 (128 bytes) ROOT LEAK: 0x600000cb0100 [128] 1 (128 bytes) ROOT LEAK: 0x600000cb0180 [128] 1 (128 bytes) ROOT LEAK: 0x600000cb0200 [128] 1 (128 bytes) ROOT LEAK: 0x600000cb0280 [128] 1 (128 bytes) ROOT LEAK: 0x600000cb0300 [128] 1 (128 bytes) ROOT LEAK: 0x600000cb0380 [128] 1 (128 bytes) ROOT LEAK: 0x600000cb0400 [128] - after this commit, I'm getting > 0 leaks for 0 total leaked bytes.
- Loading branch information