Overview
The app targets users on low-end Android devices (2GB RAM common in target markets). Long sessions accumulate memory from image caches, metrics buffers, search indexes, and Redux-like subscription closures. No cleanup mechanism exists to respond to OS memory pressure warnings. iOS calls didReceiveMemoryWarning and Android fires onTrimMemory; ignoring these leads to OOM process kills.
Specifications
Features:
memoryPressureService subscribes to native memory warning events
- On warning: flush metrics buffers, clear non-critical image cache, compact search index
- Expose
memoryPressureLevel in deviceStore (normal, warning, critical)
critical level triggers degradationStore.disableFeature for high-memory features
Tasks:
- Create
src/services/memoryPressureService.ts
- Use
AppRegistry.registerHeadlessTask or RN's internal 'memoryWarning' event
- On warning, call
imageCache.clearNonCritical(), metricsService.flush(), searchIndex.compact()
- Dispatch
setMemoryPressureLevel to deviceStore
- Add unit test simulating memory warning event
Impacted Files:
src/services/memoryPressureService.ts (create)
src/store/slices/deviceStore.ts
src/store/slices/degradationStore.ts
Acceptance Criteria
- Memory warning event triggers cleanup of non-critical caches
deviceStore.memoryPressureLevel updates on warning
- Critical pressure disables at least one high-memory feature via
degradationStore
- Unit test confirms cleanup methods called on warning event
Overview
The app targets users on low-end Android devices (2GB RAM common in target markets). Long sessions accumulate memory from image caches, metrics buffers, search indexes, and Redux-like subscription closures. No cleanup mechanism exists to respond to OS memory pressure warnings. iOS calls
didReceiveMemoryWarningand Android firesonTrimMemory; ignoring these leads to OOM process kills.Specifications
Features:
memoryPressureServicesubscribes to native memory warning eventsmemoryPressureLevelindeviceStore(normal,warning,critical)criticallevel triggersdegradationStore.disableFeaturefor high-memory featuresTasks:
src/services/memoryPressureService.tsAppRegistry.registerHeadlessTaskor RN's internal'memoryWarning'eventimageCache.clearNonCritical(),metricsService.flush(),searchIndex.compact()setMemoryPressureLeveltodeviceStoreImpacted Files:
src/services/memoryPressureService.ts(create)src/store/slices/deviceStore.tssrc/store/slices/degradationStore.tsAcceptance Criteria
deviceStore.memoryPressureLevelupdates on warningdegradationStore