android-memory-storage-pro
Skill8 starsChanged 12 days agoMITView on GitHub
Audits Android apps for memory and on-device storage problems — Context, View, listener, and Fragment-binding leaks; bitmap decode size; unbounded caches; onTrimMemory handling; largeHeap; low-memory kills and process death; app-specific vs shared storage, broad storage permissions, SharedPreferences on the main thread, deprecated security-crypto, Auto Backup rules, unbounded disk caches, free-space handling, StrictMode, and app size. Use when investigating OOMs, leaks, LMK kills, storage complaints, Play storage-permission rejections, restore crashes, or when reviewing code that caches, decodes images, or writes files.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- android-accessibility-proSkill
- android-adaptive-layout-proSkill
- android-compose-proSkill
- android-coroutines-proSkill
- android-design-system-proSkill
- android-gradle-architecture-proSkill
- android-library-proSkill
- android-modularization-proSkill
- app-intents-proSkill
- beta-deployment-proSkill
- coredata-swift6-proSkill
- cross-platform-parity-proSkill
- flaky-tests-proSkill
- foundation-models-proSkill
- instruments-profiling-proSkill
- linting-proSkill
- localization-proSkill
- motion-design-proSkill
- r8-shrink-proSkill
- store-compliance-proSkill
- swift-accessibility-proSkill
- swift-adaptive-layout-proSkill
- swift-concurrency-proSkill
- swiftdata-proSkill
- swift-design-system-proSkill
- swift-docc-proSkill
- swift-error-handling-proSkill
- swift-library-proSkill
- swift-logging-proSkill
- swift-memory-storage-proSkill
- swift-modularization-proSkill
- swift-package-proSkill
- swift-testing-proSkill
- swiftui-proSkill
- visionos-proSkill
- xcode-security-proSkill
- xml-to-compose-migration-proSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Footprint: Check image loading, in-memory caches, list loading, trim-memory handling, and manifest heap flags using …
- Very specific: line 20
Evidence: When the user reports a symptom (OOM, LMK kills, ANRs on disk, storage growth), or before you claim a fix worked, use …
- Very specific: line 24
Official companion: when Google's Android skills (android/skills, Apache-2.0) are installed, see android-profiler (Android Studio profilers …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Audit Android code for memory and storage problems. This is the deep-review companion to the always-on android-memory-management.md and android-storage-management.md rules: the rules steer while writing; this skill traces ownership, footprint, and file placement across whole features and the manifest. Report only genuine problems.
Applies to Compose and View-based apps. If asked to fix rather than review, make the changes directly and summarize them in the same file-by-file format.
Review process:
- Leaks. For every long-lived object (singletons,
objects, companion objects, ViewModels, Hilt@Singletons, services), check what it holds and what it registers, usingreferences/leaks.md. Confirm the reference chain from a GC root before reporting. - Footprint. Check image loading, in-memory caches, list loading, trim-memory handling, and manifest heap flags using
references/memory-footprint.md. - Storage. For every file write, preference, database, permission, and backup rule, check location, API, threading, size caps, and backup behavior using
references/storage-layout.md. - Evidence. When the user reports a symptom (OOM, LMK kills, ANRs on disk, storage growth), or before you claim a fix worked, use
references/measuring.mdto reproduce and confirm it with LeakCanary, the Memory Profiler,dumpsys, StrictMode, orApplicationExitInfo.
For a partial review (only leaks, only storage), load only the matching reference.
Official companion: when Google's Android skills (android/skills, Apache-2.0) are installed, see android-profiler (Android Studio profilers and PerfettoSQL). Use it to gather evidence in step 4; this skill decides what the evidence means and what to fix.
Core Instructions
- A leak finding names the chain:
AnalyticsTracker(singleton) →listener→ProfileFragment→ its view tree. "Might leak" without a chain isn't a finding. - Size findings in bytes: "decodes a 4000×3000 photo as ARGB_8888 for a 64dp avatar: ~48 MB" is actionable.
- Storage findings name the consequence: Play rejection (broad storage or media permissions), restore crash (Keystore-encrypted file in backup), data loss (needed files in
cacheDir), ANR (commit()on the main thread), or growth without bound. - Severity by user impact: crash or data loss (OOM on a common flow, restore crash, Play policy violation, secrets in plain files) > degraded (leaked screens, unbounded caches, main-thread I/O, backup bloat) > hygiene (no StrictMode in debug, missing cache cap on a small cache).
- Cross-reference, don't duplicate: coroutine scope lifetime belongs to
android-coroutines-pro; recomposition cost toandroid-compose-pro; R8 and resource shrinking tor8-shrink-pro; module placement of data sources toandroid-modularization-pro.
Output Format
Organize findings by file. For each issue: file/line, the problem, the measured or estimated cost (bytes, objects, or files), and a brief before/after. Skip clean files. End with a prioritized summary.
Example finding:
LocationTracker.kt
Line 14: a singleton holds the Activity it was first called from, leaking that screen for the life of the process.
// Before
object LocationTracker {
private lateinit var context: Context
fun start(context: Context) { this.context = context; /* ... */ }
}
// After: inject the application context; nothing screen-scoped is stored
@Singleton
class LocationTracker @Inject constructor(
@ApplicationContext private val context: Context,
)Summary
- Crash risk:
AvatarViewdecodes full-size photos (~48 MB each) withBitmapFactory.decodeFile; OOM on low-RAM devices. - Play policy:
READ_MEDIA_IMAGESrequested to pick one profile photo; use the Photo Picker. - Degraded:
LocationTrackerleaks the first Activity; SharedPreferencescommit()on the main thread inSettingsViewModel.
End of example.
References
references/leaks.md— Context and View references in long-lived objects, listeners and callbacks, ComposeDisposableEffect, Fragment view binding, handlers and inner classes, services, WebView.references/memory-footprint.md— bitmap sizing with Coil and ImageDecoder, LruCache sizing, onTrimMemory levels on Android 14+, Paging, hot-path allocation, largeHeap, low-RAM devices, process death.references/storage-layout.md— the location decision table, scoped storage, MediaStore, Photo Picker, SAF, Play permission policies, DataStore and Room, Keystore encryption, Auto Backup rules, AtomicFile, free space and cache quotas, app size.references/measuring.md— LeakCanary (debug and instrumentation), Memory Profiler heap dumps,dumpsys meminfo,ApplicationExitInfo, Macrobenchmark, Perfetto, StrictMode, inspecting app storage withadb.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

