5. Zero out memory on free instead of on allocation for ZRAM compression
In plain words
If your custom allocator zeroes memory, consider zeroing on free() instead of on allocation, so freed space on partly used 16 KB pages compresses well in ZRAM. This is a recommendation, not a requirement.
- Applies to custom allocators that zero memory, such as for security or zero-initialized allocations.
- On 16 KB devices, a page with even one live object stays resident or gets swapped to ZRAM.
- Leftover garbage data (stale pointers, strings) on freed parts of that page compresses poorly.
- Zeroing on free makes idle memory on partially filled pages compress to almost nothing, so pinned pages waste less swap space.
- At free() the memory is already hot in the CPU cache, avoiding additional cache misses later.
From the official text
Android uses compressed swap (ZRAM) to keep background apps in memory. On 16 KB devices, if a page holds even one live object, the entire 16 KB page stays resident or gets swapped to ZRAM. Leftover garbage data (such as stale pointers and strings) on previously freed parts of that page compresses poorly. If your …
Read the full official text ↗ Open in the StoreRules library Ask whether your app complies
Change history
No substantive change since StoreRules began tracking it.
Developers' cases about this clause
No cases yet.