Android Performance Optimization Flashcards
7 cards from real Android Development practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Android Performance Optimization flashcards as text
Which tool in Android Studio provides a real-time graph of CPU, memory, network, and battery usage for a running app?
Answer: Android Profiler
Android Profiler provides real-time monitoring of CPU, memory, network, and energy usage directly within Android Studio.
What is the primary cause of 'jank' (dropped frames) in Android applications?
Answer: UI thread work taking longer than 16ms per frame
Android targets 60fps, giving each frame 16ms; if the UI thread takes longer than that for a frame, the frame is dropped, causing jank.
Which class should you use to run CPU-intensive work off the main thread while easily posting results back to the UI thread?
Answer: Coroutines with Dispatchers.IO
Kotlin Coroutines with Dispatchers.IO (for IO/CPU work) and Dispatchers.Main (for UI updates) is the modern, recommended approach for off-main-thread work.
What does the term 'memory leak' mean in Android development?
Answer: An object is kept in memory longer than its intended lifecycle
A memory leak occurs when references prevent the garbage collector from reclaiming objects whose lifecycle has ended, such as an Activity referenced by a static field.
Which Android tool helps detect memory leaks by watching for destroyed objects that are still referenced?
Answer: LeakCanary
LeakCanary is a popular open-source library that automatically detects memory leaks in Android apps by using weak references and heap dumps.
What is the recommended way to load large bitmaps efficiently to avoid OutOfMemoryError in Android?
Answer: Use BitmapFactory.Options to subsample the bitmap before decoding
Setting BitmapFactory.Options.inSampleSize decodes a subsampled version of the bitmap, reducing memory usage significantly before the bitmap is loaded into memory.
Which mode in Android can developers enable to detect accidental disk or network access on the main thread?
Answer: StrictMode
StrictMode detects and reports violations such as disk reads/writes and network calls on the main thread, helping developers catch performance mistakes early.