Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use vmstate for memory leak regress tests (re: ad9a921)
'ps' does not always give reliable results; on macOS, 'ps' appears to produce nondeterministic (i.e. randomly varying) results for 'vsz' and 'rss', making it unusable for memory leak tests. See: #64 (comment) and further comments. So let's compile in the vmstate builtin so that we can make sure to measure things properly. It also reports bytes instead of 1024-byte blocks, so smaller leaks can be detected. To be decided: whether or not to disable the vmstate builtin for release builds in order to save about 12K in the ksh binary. src/cmd/ksh93/data/builtins.c: - Add vmstate to the list of builtins that are compiled in. src/cmd/ksh93/tests/leaks.sh: - getmem(): get size using: vmstate --format='%(busy_size)u' (Using busy_size instead of size seems to make more sense as it excludes freed blocks. See vmstate --man) - Introduce a $unit variable for reporting leaks and set it to 'bytes'; this makes it easier to change the unit in future. - Since the tests are now more sensitive, initialise all variables before use to avoid false leak detections. - The last test seemed to need a few more 'read' invocations in order to get memory usage to a steady state before the test.
- Loading branch information