Avoid lambda code to cache computer snapshot
The lambda will automatically retain a reference for use within the code block. In addition, snapshotComputer() also creates a new object for the snapshot everytime. If the lambda is called multiple times and some places keep them for a long time, the snapshot object becomes huge. It causes OOM in the system_server process and leads to platform reset. To avoid the problem, use Supplier instead and then gain snapshot the supplier. Bug: 381996338 Flag: EXEMPT bugfix Test: atest FrameworksMockingServicesTests:com.android.server.pm Change-Id: I57422392167012905243db0856b6eb5648b56489
Loading
Please register or sign in to comment