Close a file descriptor before losing its reference.
In ActivityManagerService.profileControl(..), a duplicate of 'mProfileFd' is passed to the app via proc.thread.profilerControl(..) as the output file of profiling trace. 'mProfileFd' itself is set to null shortly after. This made the ParcelFileDescriptor object referred by 'mProfileFd' unreachable, but the file descriptor remained open until next garbage collection, which would close the file descriptor before deallocating it. This behavior was not harmful to ActivityManagerService, but at system level the file was kept open for longer than it is needed. Other entities on the system that are interested in the same file may get confused if they are monitoring the file's status. This CL closes the file descriptor promptly after it becomes useless. More details can be found at b/33300094#comment3. Bug: b/33300094. Test: Flashed angler-eng build to a Nexus 6P and it worked as expected. Change-Id: Ifa511dea5101a854c5db5f369504cd04e4425f43
Loading
Please register or sign in to comment