Skip to main content
InterviewHubPRO
Section Overview
Q37

Question 37 of 50

Part 3: ART Internals, Memory Leak Profiling & Production Hardening (25 - 35)

74%
Android & Jetpack Compose (50 Qs)•Part 3: ART Internals, Memory Leak Profiling & Production Hardening (25 - 35)

Jetpack Compose State Stability: `@Stable`, `@Immutable`, and Collections stability.

senior LevelPerformanceMemory ManagementDocker & Containers

In Simple Words: In Compose, a function can only be skipped during recomposition if all its parameters are proven to be Stable:

  • Primitives & Strings: Automatically stable.
  • The List Problem: Standard Kotlin List<T> is an interface. Because a mutable ArrayList can be passed as a List, the Compose compiler treats standard collections as Unstable, causing views to needlessly recompose on every frame!
  • Fixes:
    1. Use Kotlinx Immutable Collections (ImmutableList<T>).
    2. Annotate custom UI data models with @Immutable or @Stable.
    3. Pass lambdas as method references or wrap in remember.