Mobile App Architecture, Lifecycle, and Performance Questions
Cross-platform mobile engineering concerns above the language layer: the app and component lifecycle, state preservation across process death, memory and resource management on constrained devices, fragmentation, and performance optimization. Covers the architectural and runtime reasoning shared by iOS and Android work. A platform-agnostic mobile competency.
Given a baseline: cold start 4.0s, warm start 1.2s, and first-render accounts for 65% of cold start time (heavy initialization and synchronous network calls), propose a prioritized plan with concrete engineering changes to reduce cold start by 50% while keeping feature parity. Include quick wins and longer-term refactors.
Refactor the Swift code below to avoid a retain cycle without leaking, and explain why your solution is safe.
class MyViewController: UIViewController {
var loader: NetworkLoader?
override func viewDidLoad() {
super.viewDidLoad()
loader?.load { data in
self.updateUI(with: data)
}
}
func updateUI(with data: Data) { /* update views */ }
}
Show at least two valid refactorings (capture list or alternate ownership) and explain lifetime implications.
Implement a thread-safe LRU cache in Java or Kotlin suitable for storing Bitmaps in an Android app. Requirements: provide get(key) and put(key, bitmap) with O(1) operations, bound total memory used by stored Bitmaps by maxMemoryBytes, evict least-recently-used entries when adding an item would exceed the limit, and support concurrent access from multiple threads. Describe the API and key implementation details (data structures and synchronization strategy).
What are common causes of retain cycles and memory leaks in Flutter apps? Discuss scenarios such as State objects capturing callbacks or Streams without cancelling, Timers not cancelled on dispose, holding BuildContext across async gaps, plugin native resources not disposed, and global singletons that keep widget-related references.
Write an approach and sample instrumented test for Android that detects a memory leak after running a user scenario. The test should: warm up the app, measure heap size before the scenario, run the scenario, force GC multiple times, measure heap again, take heap snapshot if supported, and fail if the retained memory for target classes exceeds a threshold. Provide pseudocode/test structure and explain pitfalls such as GC nondeterminism, device variability, and mitigation strategies (warmups, retries, baseline comparisons).
Unlock Full Question Bank
Get access to all Mobile App Architecture, Lifecycle, and Performance interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.