free gralloc buffers as soon as possible (when a surface is not visible any longer), client who have the buffers still mapped won't crash, btu may see garbage data
diff --git a/libs/surfaceflinger/LayerBitmap.h b/libs/surfaceflinger/LayerBitmap.h
index 824e0f2..f3636c0 100644
--- a/libs/surfaceflinger/LayerBitmap.h
+++ b/libs/surfaceflinger/LayerBitmap.h
@@ -110,7 +110,8 @@
     status_t setSize(uint32_t w, uint32_t h);
 
     sp<Buffer> allocate();
-
+    status_t free();
+    
     sp<const Buffer>  getBuffer() const { return mBuffer; }
     sp<Buffer>        getBuffer()       { return mBuffer; }