inessential by Brent Simmons

3 laws

The Three Laws of iPhone apps:

  1. An app must not allocate memory or, through inaction, allow memory to be allocated.

  2. An app must obey all didReceiveMemoryWarnings given to it by the system, except where such orders would conflict with the First Law.

  3. An app must continue to run and not crash as long as such running does not conflict with the First or Second Law.


#1 is a bit stringent, but it’s always worth keeping in mind as a paradisiacal condition to strive for, however impossible.

With #2 there shouldn’t be such a conflict, obviously. But possibly worth spelling out anyway.

#3 seems to be just right.

But #1 is my favorite, the one I keep replaying in my head.

Are there any non-geeks in the audience? If so, allow me to point to the Three Laws of Robotics.

Update 12:12 am: I’ve had some questions about this. Obviously, you have to allocate memory. To suggest you shouldn’t is pure hyperbole. My point is just that allocating memory is expensive, and sometimes it can be avoided.

When you run into trouble, use Shark and Instruments to find out what’s going on.