BitmapTest: Fix initial memory measurement
There is a Surface created for a testDrawingHardwareBitmapNotLeaking
test.
Buffers allocated for the bufferqueue for this surface
are not allocated as Surface is created, but on demand.
That make it possible for some buffers being allocated
a way later then two first cycles.
Test: this
Merged-In: I721c8bd0c03d99cb49903b3c3a83134d52d65ff9
Change-Id: I721c8bd0c03d99cb49903b3c3a83134d52d65ff9
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
index 1ef7c87..9bb13c5 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
@@ -1512,15 +1512,15 @@
Debug.MemoryInfo meminfoStart = new Debug.MemoryInfo();
Debug.MemoryInfo meminfoEnd = new Debug.MemoryInfo();
int fdCount = -1;
+ // Do a warmup to reach steady-state memory usage
+ for (int i = 0; i < 50; i++) {
+ test.run();
+ }
+ runGcAndFinalizersSync();
+ Debug.getMemoryInfo(meminfoStart);
+ fdCount = getFdCount();
+ // Now run the test
for (int i = 0; i < 2000; i++) {
- if (i == 2) {
- // Not really the "start" but by having done a couple
- // we've fully initialized any state that may be required,
- // so memory usage should be stable now
- runGcAndFinalizersSync();
- Debug.getMemoryInfo(meminfoStart);
- fdCount = getFdCount();
- }
if (i % 100 == 5) {
assertNotLeaking(i, meminfoStart, meminfoEnd);
assertEquals(fdCount, getFdCount());