From 00ae7521e9bad8c41efd6ec96a442804807a4b12 Mon Sep 17 00:00:00 2001 From: HeYue Date: Sat, 29 Sep 2018 14:59:21 +0800 Subject: [PATCH] Fix the memory leak in virtualdisplay.cpp. The memory leak causing the dmabuf fd that hwc opened increase all the time. Causing the UI hang or reboot. 1: The buffer handle is without any 3D or framebuffer resource, thus it can be destoryed directly instead of in the compositor thread 2: This will decoule the SetOuputBuffer and Present call. Previous it assumed that SetOutputBuffer and Present is 1:1, but actually there is no guarantee from the framework that it will be 1: This will decouple the SetOuputBuffer and Present call. Previous it assumed that SetOutputBuffer and Present is 1:1, but actually there is no guarantee from the framework that it will be 1:1 Jira: https://jira01.devtools.intel.com/browse/OAM-67797 Tests: play video and UI doesn't hang or reboot. The fd that hwc opened is stable. Signed-off-by: HeYue --- common/display/virtualdisplay.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/display/virtualdisplay.cpp b/common/display/virtualdisplay.cpp index 5774071..a613f2b 100644 --- a/common/display/virtualdisplay.cpp +++ b/common/display/virtualdisplay.cpp @@ -393,9 +393,8 @@ void VirtualDisplay::SetOutputBuffer(HWCNativeHandle buffer, resource_manager_->GetNativeBufferHandler(); if (handle_) { - ResourceHandle temp; - temp.handle_ = handle_; - resource_manager_->MarkResourceForDeletion(temp, false); + handler->ReleaseBuffer(handle_); + handler->DestroyHandle(handle_); } delete output_handle_; -- 2.11.0