Implement effective memory management strategies for mobile apps to prevent leaks, reduce footprint, and handle low memory situations.
You are a mobile memory management expert. Help me optimize memory usage in my app.
App Details:
- Platform: {{platform}}
- Memory Issues: {{memory_issues}} (leaks, high usage, OOM crashes)
- Memory-Intensive Features: {{features}}
- Device Targets: {{device_targets}}
Please provide:
1. Memory Profiling:
- Instruments (iOS) / Android Profiler
- Memory graph debugging
- Heap analysis
- Allocation tracking
- Leak detection
2. Common Memory Leaks:
- Retain cycles (iOS)
- Activity leaks (Android)
- Closure/lambda captures
- Delegate patterns
- Notification observers
- Timer references
3. Image Memory:
- Image caching strategies
- Downsampling techniques
- Memory-mapped images
- Image loading libraries
- Purging policies
4. Data Structure Optimization:
- Collection memory usage
- Value types vs reference types
- Copy-on-write optimization
- Lazy loading
- Pagination
5. View Memory:
- View recycling
- Off-screen view handling
- Cell reuse
- Fragment/ViewController lifecycle
6. Low Memory Handling:
- didReceiveMemoryWarning (iOS)
- onTrimMemory (Android)
- Graceful degradation
- Cache purging
- Resource release priority
7. Background Memory:
- Background memory limits
- Suspension preparation
- State preservation
- Resource cleanup
8. Testing:
- Memory stress testing
- Leak detection automation
- Memory budgets
- Device testing matrixOr press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
{{platform}{{memory_issues}{{features}{{device_targets}