You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix memory leaks and add warm-up step in fixture.c
The original plan was to explore adding a warm-up step to the
measurement function, motivated by a privately implemented earlier
version that included this feature and successfully passed tests for
queue-related functions, unlike the current stricter version which
lacked it and failed those tests. Before implementing this change,
Valgrind inspection was performed on the original code without the
warm-up step, revealing memory leaks with 43,632 bytes lost across
909 blocks per test. Analysis showed that the initialization function
was being called repeatedly within the testing loop, each time
reallocating the context array without any provision to free prior
memory allocations. This uncontrolled repetition caused memory to
accumulate not freed over multiple test iterations, leading to the
observed leaks. To address this issue in the original code, the
initialization process was revised to execute only once before testing
begins, and a cleanup was added to release all allocated memory
when testing concludes, fully resolving the memory leak problem.
After resolving the memory leaks, the warm-up step was added to
discard the first batch of data, and tests were conducted to determine
its impact on the constant-time behavior of queue insertion and removal
functions. To isolate its effect, the original flawed memory release
approach was temporarily restored, revealing persistent memory-related
issues that prevented reliable test outcomes. Once the corrected memory
release method was applied alongside the warm-up step, all
memory-related problems disappeared, and the tests passed successfully.
The decision to retain the warm-up code is based primarily on the
dudect paper, which points out that factors like cache misses or memory
allocation delays could, under different conditions, affect t-test
results. The expectation is that in certain future test scenarios, the
warm-up step may enhance t-test precision, justifying its inclusion in
this submission.
Change-Id: I06a74a7ecf1ca08f79ded70d91e4b33ed7cf141b
0 commit comments