Performance, under the hood · check

Know Frames and memory already?

One question for each of the 5 puzzles in this module. A right answer marks that puzzle as passed, so you can jump ahead. A wrong one tells you which puzzle to start with. Nothing is sent anywhere: it's saved in this browser.

Puzzle 5: Who puts pixels on screen

Your app's main thread and RenderThread finished early, but the GPU is still filling the buffer at the refresh. What does the display show?

Not quite. The pixels are written by the GPU; until it's done, there's no new buffer. Learn it in puzzle 5 →

Right. No finished buffer, no new picture.

Not quite. SurfaceFlinger only takes finished buffers between refreshes, so there's no half picture. Learn it in puzzle 5 →

Puzzle 6: The late frame

A frame's main thread finished well before the deadline, but FrameTimeline marks it late. What can explain it?

Not quite. The expected window is the app's budget; the GPU work came on top. Learn it in puzzle 6 →

Not quite. The Actual Timeline ends at the later of posting and the GPU finishing. Learn it in puzzle 6 →

Right. Actual ends at max(GPU, post time).

Puzzle 7: What garbage is

A function creates a User and keeps it only in a local variable. After the function returns, what is the User?

Not quite. Who created it doesn't matter; what matters is whether a chain from a root still leads to it. Learn it in puzzle 7 →

Right. No chain from a root means garbage.

Not quite. It becomes garbage then; the collector frees it later, when it runs. Learn it in puzzle 7 →

Puzzle 8: What the collector costs

Why is creating an object in ART cheap?

Not quite. It doesn't; allocation is fast because the space is the thread's own and contiguous. Learn it in puzzle 8 →

Right. Own space, one pointer bump.

Not quite. No search, no shared list: the thread moves its own marker in its own TLAB. Learn it in puzzle 8 →

Puzzle 9: What a heap dump proves

An old Activity has a shallow size of 400 bytes and a retained size of 12 MB. What does freeing it save?

Right. Retained size is what you really get back.

Not quite. A destroyed Activity is collected like any object, once unreachable. Learn it in puzzle 9 →

Not quite. That's shallow size; retained size counts everything that goes with it. Learn it in puzzle 9 →

Back to the overview →