Android
Cold vs Warm vs Hot Start in Android
What actually happens in each launch type, how to measure them reliably, and the practical techniques that shrink cold-start time.
Sagar Bhandari 2 min read
- #performance
- #app startup
- #baseline profiles
- #macrobenchmark
Table of contents
Start-up time is the first performance impression your app makes. Android distinguishes three kinds of launch, and each needs a different mental model.
The three launch types
| Type | Process exists? | Activity exists? | What runs |
|---|---|---|---|
| Cold | No | No | Process creation, Application.onCreate, Activity creation, first frame |
| Warm | Yes | No (or recreated) | Activity creation and first frame |
| Hot | Yes | Yes (in memory) | Bring activity to front |
Cold start is the slowest and the one worth optimising first — improvements there usually help warm and hot starts too.
Measure before you optimise
Quick measurement from the command line:
Bash
adb shell am force-stop com.example.app
adb shell am start -W -n com.example.app/.MainActivity
# TotalTime: 812For reliable numbers use Macrobenchmark, which runs on a real device, repeats iterations and controls compilation state:
Kotlin
@RunWith(AndroidJUnit4::class)
class StartupBenchmark {
@get:Rule val rule = MacrobenchmarkRule()
@Test fun coldStart() = rule.measureRepeated(
packageName = "com.example.app",
metrics = listOf(StartupTimingMetric()),
iterations = 10,
startupMode = StartupMode.COLD,
) {
pressHome()
startActivityAndWait()
}
}Techniques that work
- Do less in
Application.onCreate(). Defer SDK initialisation that isn't needed for the first screen. - Lazy-load heavy objects with
by lazyor dependency-injection providers. - Ship Baseline Profiles so critical code paths are precompiled instead of interpreted/JIT-compiled on first run.
- Avoid disk and network on the main thread during start-up.
- Keep the first layout shallow and render lists efficiently.
- Profile memory: large allocations at start-up trigger GC pauses.
Kotlin
class App : Application() {
val analytics by lazy { Analytics.create(this) } // created on first use
override fun onCreate() {
super.onCreate()
// Only what the first frame needs.
}
}Key takeaways
- Know which launch type you're measuring.
- Use Macrobenchmark for numbers you can trust.
- Most wins come from doing less, later — and from Baseline Profiles.