21.9 · Memory you can count: allocations, dirty versus clean pages and decoded images

Memory problems are about how much is resident and dirty and how many allocations you make, not how large your files are. Both can be counted.

Mental model. Count heap blocks, separate dirty from clean pages, and size a bitmap from its pixels, not its file.

Resident memory

What the memory limit actually counts, and what an image costs when decoded.

  1. What counts toward an app’s memory limit: why is reserved memory free, a mapped file cheap, and the same file read into a buffer expensive? 21.9.1 · L5
    The limit that gets an app killed is about dirty memory (plus compressed memory), what the system cannot simply discard or reload from disk (Q162). In the…
  2. A 2 MB JPEG costs how much memory once it is shown, and what does downsampling at decode time change? 21.9.2 · L3
    A compressed file's size says nothing about its memory cost. A decoded bitmap needs width × height × bytes per pixel (4 for 8-bit RGBA), and the row stride may…

More in Performance & energy