Why iOS App Storage Size Mismatches System Settings and How Kuaishou Fixed It
This article investigates why the storage size shown inside iOS apps often differs from the total size displayed in the iPhone Settings, analyzes four main causes—including app bundle size, binary vs decimal units, measurement scope, and cache path handling—and demonstrates how Kuaishou aligned its storage reporting with the system through experiments and code changes.
Background
Users notice that the used storage displayed inside many iOS apps does not match the total size shown in the iPhone Settings. The discrepancy can affect user trust and raise concerns about app quality and data security.
Investigation of Differences
Reason 1: App Bundle Size
iOS Settings shows "App Size" and "Documents & Data" separately. Most apps (except QQ) do not include the app bundle size in the "Used" figure shown inside the app.
Reason 2: Binary vs Decimal Units
Manufacturers label storage in decimal (1000) units, while many systems use binary (1024). iOS uses decimal units for its storage display, which leads to a 4.9%–7.4% discrepancy at the MB/GB level.
Reason 3: Measurement Scope
File size (actual bytes) and disk‑occupied size differ because the file system allocates whole blocks (typically 4 KB). Small files therefore occupy more disk space than their actual size, inflating the total.
Reason 4: Path Inclusion
iOS does not count Library/Caches when calculating free space via NSURLVolumeAvailableCapacityForImportantUsageKey . The system excludes this directory from the used‑space total, while some apps count it.
Verification Experiments
Using a jail‑broken iPhone, the author injected files into the sandbox and measured the increase on the "iPhone Storage" page. The increase matched the disk‑occupied size (e.g., 40 MB for 10 000 × 1 KB files), confirming that iOS uses disk‑occupied size for its total.
<code>for i in {1..10000}; do dd if=/dev/zero of=file$i.txt bs=1000 count=1; done</code>Additional verification used stat.h st_blocks to compute block count (8‑block multiples) and confirmed APFS uses 4 KB logical blocks.
Conclusion
iOS calculates app storage as:
iOS 16 and earlier: App bundle size + sandbox size (excluding Library/Caches)
iOS 17 and later: Sandbox size only (including Library/Caches)
The system uses decimal units and rounds to two decimal places.
Kuaishou’s Alignment
Kuaishou updated its app to:
Include the app bundle size in its own total.
Switch storage unit conversion to decimal.
Calculate total using disk‑occupied size.
Align the path scope with iOS system calculation.
After the changes, the difference between the app’s reported used space and the iPhone Settings total is only 0.43%.
Technical & User Perspective
Accurate storage reporting improves user trust and simplifies storage management, while the technical solution required understanding of APFS block allocation, unit conversion, and system APIs.
Kuaishou Frontend Engineering
Explore the cutting‑edge tech behind Kuaishou's front‑end ecosystem
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.