Merge "ImageReader/Writer: Only register 1 buffer for native allocation" into nyc-dev

This commit is contained in:
Eino-Ville Talvala
2016-05-03 00:14:55 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 3 deletions

View File

@@ -157,8 +157,11 @@ public class ImageReader implements AutoCloseable {
// Estimate the native buffer allocation size and register it so it gets accounted for // Estimate the native buffer allocation size and register it so it gets accounted for
// during GC. Note that this doesn't include the buffers required by the buffer queue // during GC. Note that this doesn't include the buffers required by the buffer queue
// itself and the buffers requested by the producer. // itself and the buffers requested by the producer.
mEstimatedNativeAllocBytes = ImageUtils.getEstimatedNativeAllocBytes(width, height, format, // Only include memory for 1 buffer, since actually accounting for the memory used is
maxImages); // complex, and 1 buffer is enough for the VM to treat the ImageReader as being of some
// size.
mEstimatedNativeAllocBytes = ImageUtils.getEstimatedNativeAllocBytes(
width, height, format, /*buffer count*/ 1);
VMRuntime.getRuntime().registerNativeAllocation(mEstimatedNativeAllocBytes); VMRuntime.getRuntime().registerNativeAllocation(mEstimatedNativeAllocBytes);
} }

View File

@@ -138,11 +138,14 @@ public class ImageWriter implements AutoCloseable {
// Estimate the native buffer allocation size and register it so it gets accounted for // Estimate the native buffer allocation size and register it so it gets accounted for
// during GC. Note that this doesn't include the buffers required by the buffer queue // during GC. Note that this doesn't include the buffers required by the buffer queue
// itself and the buffers requested by the producer. // itself and the buffers requested by the producer.
// Only include memory for 1 buffer, since actually accounting for the memory used is
// complex, and 1 buffer is enough for the VM to treat the ImageWriter as being of some
// size.
Size surfSize = SurfaceUtils.getSurfaceSize(surface); Size surfSize = SurfaceUtils.getSurfaceSize(surface);
int format = SurfaceUtils.getSurfaceFormat(surface); int format = SurfaceUtils.getSurfaceFormat(surface);
mEstimatedNativeAllocBytes = mEstimatedNativeAllocBytes =
ImageUtils.getEstimatedNativeAllocBytes(surfSize.getWidth(),surfSize.getHeight(), ImageUtils.getEstimatedNativeAllocBytes(surfSize.getWidth(),surfSize.getHeight(),
format, maxImages); format, /*buffer count*/ 1);
VMRuntime.getRuntime().registerNativeAllocation(mEstimatedNativeAllocBytes); VMRuntime.getRuntime().registerNativeAllocation(mEstimatedNativeAllocBytes);
} }