summaryrefslogtreecommitdiff
path: root/tests/DynamicCodeLoggerIntegrationTests/src/cpp/test_executable.cpp
diff options
context:
space:
mode:
authorGarfield Tan <xutan@google.com>2019-02-07 14:38:38 -0800
committerGarfield Tan <xutan@google.com>2019-02-08 17:22:40 -0800
commit26835f0b47f8a8ef1ed88553ffeb4e526b183632 (patch)
treef90297caca33c0d954856397ef23c71e085505c6 /tests/DynamicCodeLoggerIntegrationTests/src/cpp/test_executable.cpp
parent0528cd9d7df10573d2f98b760964992d96dd33ec (diff)
Track and reset mock to avoid mem leaks.
When a test calls a mock with another mock, it creates a chain of reference inside MockHandlerImpl because invocation is saved in invocationContainer for stubbing record. If InlineDexmakerMockMaker, the MockHandlerImpl is then stored in a mock map to provide stubbing behavior for future use, and will be cleaned up from the mock map when the mock object is reclaimed by GC. Since InlineDexmakerMockMaker only cleans up the map at most once every 16s, we need 16s plus a GC pass to shorten the chain of ref by one node when the chain doesn't form a ring. This CL resets all created mocks after running each test suite. Consequently it uses a brand new MockHandlerImpl to replace the original one and break down the reference chain. One thing that's worth noting is this is not a complete solution to this issue, as the MockCreationListener is held in a ThreadLocal, which means we can only get notified for mocks created in the same thread, but this is enough for now because it catches many large retainers like ATMS and WMS. Bug: 123984854 Test: atest WmTests can run to the end w/o hanging or crashing. Note this only fixes one of two memory issues we found in the bug. Change-Id: Iab08c4a324f4de593323d4914256970d7bc1a150
Diffstat (limited to 'tests/DynamicCodeLoggerIntegrationTests/src/cpp/test_executable.cpp')
0 files changed, 0 insertions, 0 deletions