]> Cypherpunks repositories - gostls13.git/commit
runtime/debug: make TestFreeOSMemory more robust
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 10 Nov 2021 22:03:28 +0000 (22:03 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 11 Nov 2021 20:20:42 +0000 (20:20 +0000)
commit3e94140465984ff6c8d658051d022e8eacf057c3
tree76c3999497676a66cdf3df3ccde7bb711e4538b9
parent48f1cde942959e2fc3c56973a2986c24d554c82c
runtime/debug: make TestFreeOSMemory more robust

FreeOSMemory relies on the function FreeOSMemory increasing HeapReleased
as opposed to the background scavenger, because it reads memory stats
*after* the free of a large allocation. However, before that even
happens, the background scavenger can swoop in and release all that
memory, making it appear as if FreeOSMemory didn't do anything.

This change modifies the test to just make sure that the large
allocation's memory is returned to the OS *somehow*, by the end of the
test. It doesn't really care which happens. It also increases the size
of that large allocation to increase the likelihood that the test isn't
relying 100% on the background scavenger, and that FreeOSMemory is doing
some of the work.

Fixes #49478.

Change-Id: Ief1d839753720ebb88cbb616c46302293ee2d19c
Reviewed-on: https://go-review.googlesource.com/c/go/+/363414
Reviewed-by: David Chase <drchase@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
src/runtime/debug/garbage_test.go