The mobile runtime

Constrained CPU/memory/battery, flaky networks, the sacred main/UI thread, and OS-initiated process death. Internalizing these constraints is what separates mobile from generic app dev.

About 23 min read3-question knowledge check

The mental model

A server is a tenant with a lease: it gets the CPU, RAM, and power it was provisioned, and it keeps them until you scale it down. A mobile app is a guest in someone else's house — a house that also holds the camera, the dialer, fifty other apps, and an owner who cares far more about their battery lasting until bedtime than about your background sync finishing. The operating system is the host, and it can ask you to leave at any moment, without notice, mid-sentence.

Internalising that single reversal — you do not own the machine, the OS does — is what separates mobile engineering from generic app development. Four constraints follow from it, and every one shows up in interviews:

  • The CPU, memory, and battery are shared and scarce. A budget phone in a tier-2 Indian city has 3 GB of RAM shared across everything, a thermally-throttled mid-range SoC, and a user watching their battery percentage. You are not the only process, and you are not the important one.
  • The network is flaky by default, not by exception. Trains, lifts, basements, 2G fallback, captive portals. "The request will succeed" is the wrong default; "the request will fail, hang for 30 seconds, or return partial data" is the right one.
  • The main thread is sacred. Every frame the user sees is rendered on one thread. That thread has roughly 16 milliseconds to produce a frame at 60fps (about 8 ms at 120fps). Block it for 5 seconds on Android and the OS shows an ANR ("Application Not Responding") dialog; block the main thread on iOS and the app is unresponsive and the watchdog can kill it.
  • **The OS kills your process whenever it wants.** Background your app, and when memory gets tight the OS terminates it silently — no onDestroy guarantee, no warning, no crash log. Your carefully-held in-memory state is simply gone.

The mental shortcut that explains most mobile bugs: treat every one of these as an adversary you design against, not an edge case you patch later. Engineers who treat a phone like "a server with a screen" ship apps that work on their flagship dev device and fall over on the devices most of the world actually owns.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision