Optimize custom memory allocators
通俗解读
使用自定义内存管理器、堆或 slab 分配器的应用、游戏引擎或原生库,应遵循 16 KB 页面的建议;使用标准 Android 分配器(scudo)的应用可以跳过本节。
- 仅适用于你的应用、游戏引擎或原生库实现了自定义内存管理器、堆或 slab 分配器的情况,例如自定义游戏引擎、嵌入式数据库,或嵌入 jemalloc 或 mimalloc 的运行时。
- 使用标准 Android 内存分配器(scudo)的应用可以跳过本节。
- 在 16 KB 系统上,最小物理内存单位是 4 KB 系统的四倍。
- 为 4 KB 假设设计的分配器可能会把小对象分散到多个 16 KB 页面中,并保留空内存,从而提高 RSS 并降低 ZRAM 效率。
- 如果你的代码管理自身的内存池,请遵循接下来的建议。
官方原文摘录
Note: This section applies only if your app, game engine, or native library implements a custom memory manager, heap, or slab allocator (such as in custom game engines, embedded databases, or runtimes embedding jemalloc or mimalloc). If your app uses the standard Android memory allocator (scudo), you can skip this …
阅读官方全文 ↗ 在 StoreRules 规则库中打开 询问你的应用是否合规
变更历史
自 StoreRules 开始跟踪以来没有实质性变化。
开发者关于此条款的案例
暂无案例。
下级条款
- 1. Avoid hard-coded byte thresholds for freeing memory
- 2. Fill up already-used pages first (dense-first allocation)
- 3. Align memory pools to 16 KB and keep pool sizes moderate
- 4. Release physical memory for cached large buffers immediately
- 5. Zero out memory on free instead of on allocation for ZRAM compression
- Summary of recommendations