From b3450cc177fb8b7541449bd1f28f59c0f3ab8fe0 Mon Sep 17 00:00:00 2001 From: Luden Date: Wed, 20 Apr 2016 21:22:06 +0000 Subject: camera: fix large tiler memory leakages This should fix large (>10M) tiler memory leakages that often occur when the camera is closed. There are still smaller leaks left (several 4K pages per run), but these are much less damaging. Change-Id: Icc442407d357eeff4a1bce9edeff0f186f5646d1 --- camera/ANativeWindowDisplayAdapter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp index 396e6d4..fae87a1 100644 --- a/camera/ANativeWindowDisplayAdapter.cpp +++ b/camera/ANativeWindowDisplayAdapter.cpp @@ -403,6 +403,8 @@ int ANativeWindowDisplayAdapter::disableDisplay(bool cancel_buffer) } else { + CAMHAL_LOGEA("disableDisplay: resetting mANativeWindow to NULL"); + returnBuffersToWindow(); mANativeWindow = NULL; // Clear the frames with camera adapter map mFramesWithCameraAdapterMap.clear(); @@ -475,6 +477,7 @@ CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int hei if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } @@ -489,6 +492,7 @@ CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int hei if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } @@ -510,6 +514,7 @@ CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int hei if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } @@ -542,6 +547,7 @@ CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int hei if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } @@ -595,6 +601,7 @@ CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int hei if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } @@ -712,6 +719,7 @@ status_t ANativeWindowDisplayAdapter::minUndequeueableBuffers(int& undequeueable if ( NO_INIT == ret ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } @@ -793,6 +801,7 @@ status_t ANativeWindowDisplayAdapter::returnBuffersToWindow() ret = mANativeWindow->cancel_buffer(mANativeWindow, handle); if ( NO_INIT == ret ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; return ret; } else if ( NO_ERROR != ret ) { @@ -1145,6 +1154,7 @@ bool ANativeWindowDisplayAdapter::handleFrameReturn() if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } @@ -1157,6 +1167,7 @@ bool ANativeWindowDisplayAdapter::handleFrameReturn() if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); + returnBuffersToWindow(); mANativeWindow = NULL; } -- cgit v1.1