Status: Implemented and tested

RAM & Memory Subsystem

Memory diagnostics in Android encompasses multiple distinct layers: physical hardware DRAM chips, kernel memory carve-outs, userspace available memory, compressed zRAM swap, virtual machine heaps, and kernel page allocators.

Why Hardware Utilities Report Different RAM Numbers

If your phone has an "8 GB RAM" specification, why does Android report 7.25 GB? Physical silicon contains 8,192 MB (8 GiB) of physical DRAM. However, early bootloader initialization carves out dedicated physical memory for the modem, GPU, camera ISP, and TrustZone secure OS before the Linux kernel boots. The Linux kernel's MemTotal and Android's totalMem only report memory usable by the OS. Voodoo reports both the OS-managed RAM and the physical bootloader DDR capacity where exposed.

Defining "Used" RAM Accurately

In Linux, unused RAM is wasted RAM. The kernel aggressively utilizes idle memory for disk caching (Cached) and I/O buffers (Buffers). When an app needs memory, the kernel instantly reclaims this cache. Voodoo defines Used RAM strictly as totalMem - availMem, matching Android's official memory pressure calculations.

zRAM Swap Compression

Android does not use traditional disk swap partitions due to flash wear. Instead, it creates a virtual compressed block device in RAM called zRAM. Inactive memory pages are compressed (using lz4 or zstd) and stored in zRAM, effectively expanding usable memory by 30% to 50% at the cost of minor CPU cycles.

Dedicated Physical-Memory Cross-Check (/proc/zoneinfo)

Counterfeit Android TV boxes, generic low-cost tablets, and clone phones sometimes spoof /system/build.prop or framework classes to report 4 GB or 8 GB of RAM when the board only contains 1 GB or 2 GB.

Voodoo implements a dedicated verification routine (ZoneInfoParser.kt):

  • The Buddy Allocator Truth: The Linux kernel page allocator in /proc/zoneinfo cannot be forged by userland scripts; the kernel requires genuine physical page frames to operate. Voodoo sums present and managed pages across all zones (DMA, Normal, HighMem) and multiplies by the hardware page size (typically 4,096 bytes).
  • Bootloader DRAM Properties: Voodoo checks low-level bootloader properties (ro.boot.dramsize, ro.boot.ddr_size, ro.boot.ramsize).
  • Investigative Evidence, Not Fraud Proof: Discrepancies between these numbers indicate a configuration warranting technical investigation. They do not constitute absolute legal proof of fraud, as legitimate devices may withhold bootloader properties or apply large vendor memory reservations.

How Voodoo Inspects Memory

1. Primary Call & API-Level Fallback Chain

Extracted from MemoryCollector.kt. Uses ActivityManager.MemoryInfo (API 16+ totalMem), falling back to /proc/meminfo on Android 2.3, and parses /proc/zoneinfo:

// Excerpt from com.tool3.hardwareinfo.categories.memory.MemoryCollector.kt
val actManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val memInfo = ActivityManager.MemoryInfo()
actManager.getMemoryInfo(memInfo)

val totalRamBytes = if (Build.VERSION.SDK_INT >= 16) {
    ModernMemoryHelper.getTotalMem(memInfo)
} else {
    memInfoParser.getMemTotalBytes() ?: 0L
}

// Low RAM Android Go detection (API 19+)
val isLowRam = if (Build.VERSION.SDK_INT >= 19) {
    ModernMemoryHelper.isLowRamDevice(actManager)
} else {
    false
}

// Kernel Buddy Allocator Verification
val zoneData = ZoneInfoParser.read() // /proc/zoneinfo present pages * pageSize

2. Permission & Privilege Gate

All memory inspection APIs (ActivityManager.MemoryInfo, /proc/meminfo, /proc/zoneinfo) require zero permissions.

3. Interpretation & Normalization Logic

  • Byte Formatting: Raw byte counts are formatted into binary units (MB, GB) using ByteFormatter.kt with explicit precision.
  • zRAM Extraction: Parses SwapTotal and SwapFree from /proc/meminfo to report swap capacity and current swap consumption.

4. Availability-State Triggers

  • isLowRamDevice() on Android < 4.4 triggers AvailabilityState.UNSUPPORTED.
  • Unreadable /proc/zoneinfo due to custom OEM kernel restrictions triggers AvailabilityState.UNAVAILABLE.

Subsystem Field Inventory

Field ID Display Name Type Primary Source / API Min API
memory.total_bytes Total Physical RAM INTEGER MemoryInfo.totalMem (API 16+) / /proc/meminfo API 1
memory.available_bytes Available RAM INTEGER MemoryInfo.availMem API 1
memory.used_bytes Used RAM INTEGER Calculated: totalMem - availMem API 1
memory.low_memory Low Memory State BOOLEAN MemoryInfo.lowMemory API 1
memory.zram_total_bytes zRAM Swap Total INTEGER /proc/meminfo (SwapTotal) API 1
memory.heap_max_bytes Dalvik/ART Heap Limit INTEGER Runtime.getRuntime().maxMemory() API 1
memory.ram_integrity RAM Integrity Evaluation STRING ZoneInfoParser (/proc/zoneinfo cross-check) API 1