Skip to content

Unbounded In-Memory Cache Growth #299

@annrose2277-glitch

Description

@annrose2277-glitch

Bug Report | Memory Leak Critical

Description
Multiple caches in MediaRepository (detailsCache, castCache, similarCache, logoCache, etc.) use mutableMapOf without size limits or TTL-based eviction. Long user sessions with browsing can exhaust device heap memory on TV devices with limited RAM (384-512 MB).

Steps to Reproduce
Install app on TV device with constrained memory
Browse catalog continuously for 30+ minutes
View details for 100+ different media items
Memory usage grows unbounded; app crashes or becomes sluggish
Expected Behavior
Caches should have bounded size and TTL-based eviction

Actual Behavior
Memory usage grows linearly with items accessed; no eviction policy

Environment
Platform: Android TV (low-memory devices)
Component: Media Repository
File: app/src/main/kotlin/com/arflix/tv/data/repository/MediaRepository.kt (line 110-123)
Possible Fix
Use LruCache or implement a TTL-based eviction with max size limits.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions