Hacker News new | ask | show | jobs
by extension 5250 days ago
It really irks me when crashes are made out to be the result of user actions, or some inescapable act of god. Excepting the very rare hardware fault, crashes are caused by a programmer error. PERIOD. That is all that really matters from the user's perspective. There may be some way to work around the bug by tinkering with things, but nothing the user does can ever cause a crash.

Also, it wouldn't surprise me if iOS apps crash more than Android apps, because iOS doesn't have virtual memory. When an iOS app runs out of physical memory, it gets killed. This was allegedly a design decision.

2 comments

I have been bitten twice by changes to the iOS SDK. An app that ran fine, without error, on one version of iOS would crash on a later version.

It's always something caused by a programmer, but not necessarily the app programmer...

That's not really proof that you were doing things correctly. You could well have been relying on undocumented corner case behavior that just happened to be true in one version of iOS, but not the next.

Awhile back, a bunch of apps got updated with what the authors called "fixes for iOS5." I have an app on the store that works all the way back to iOS 3.0, and it needed no updates at all for iOS5.

Occasionally Apple does take away documented, working APIs, but it's rare. In general, I'd say an app needs updates for a new version of iOS mostly because the author assumed things that weren't true.

I believe most of the "fixes for iOS 5" and "adding iOS 5 support" updates are just marketing strategies. It makes users feel that the app is up to date.

I did this recently for an app that needed no update other than a small bug fix, but I slapped on a "support for iOS 5" just for good measures.

To be fair, this is why you, as an Apple Developer, get the SDK in advance of the general public and is why Apple strongly encourages you to do your due diligence before the iOS version goes public. And they do release API diffs, too.
Ironically, Microsoft tend to make sure that this never happens inside the Windows API.
When an Android app runs of memory it also crashes, with an OutOfMemory error.
So it does.

Though it also has garbage collection, which likely prevents the kind of memory leaks that crash most iOS apps in the first place. And does it let the browser use swap? Because iOS doesn't, so web pages can crash it about as easily as apps can.

Oh how I sometimes wish I had some kind of memory management in Android ... It's a real joy when the system decides to reclaim a few thousands of of objects when the user is playing your game.
iOS and Android both have garbage collection, and it is mandatory for neither OS. (I would consider ARC garbage collection, and nothing is stopping you from running C code on Android.)
That's just wrong.

Android has garbage collection, yes.

Since iOS5 there's refcounting available, but that's far away from garbage collection. Just add some circular dependencies and refcounting will fail. And no, that's not only a theoretical problem (as everyone who used Python's refcounting before version 2 can tell you).

Since iOS5 there's refcounting

Actually, that's not true.

Since at least NeXTSTEP there's refcounting. In 1989, NeXTSTEP introduced their NSObject-based Objective-C runtime with relied on -retain and -release calls to count object references. I can only find records commenting on NSObject's support for -retain and -release, but it may have been done earlier in a different Objective-C based runtime. (And I'm certain refcounting was pioneered in earlier runtimes.)

In 1995, the OpenStep standard introduced autorelease pools, which helped automate reference counting. Calling -autorelease on an object increments the retain count and instructs the enclosing autorelease pool to decrement the count when it pops.

In 2011, Lion and iOS 5 introduced ARC – Automatic Reference Counting. It's actually a pretty sweet memory management solution where simple statically applied code transformations streamline memory management without the need of a garbage collector. As you note though, circular dependencies cannot (yet!) be handled by ARC. To assert that circular dependencies can only be handled through garbage collectors is possibly short-sighted. I know the team that implemented ARC already has prototypes that handle some kinds of circular dependencies, or warn programmers of possible circular deps in their code.

To say automatic ref counting is "far away" from garbage collection is rather disingenuous. It's simply different. Both have tradeoffs. Garbage collection handles all memory management for you; automatic reference counting still requires some manual memory management. GC gracefully deals with circular dependencies; ARC leaks memory with circular dependencies. GC requires runtime overhead in memory and clock cycles; ARC minimizes memory and CPU overhead and, when you need zero overhead, you can drop down to manual memory management.

Frankly, I far prefer ARC to GC. ARC gives me almost all the benefits with no runtime overhead. There's nothing running alongside my code that might randomly suck up cycles or pause execution, and I can always profile exactly what my users will run. Don't knock refcounting just because it's not vogue.

Reference counting does have runtime overhead, though. Incrementing and decrementing references as a reference gets passed around isn't free. If you have many small objects, the reference count itself may become a significant memory overhead. Furthermore, GC means that memory allocation can be done by allocating at the top of the heap instead of a more expensive malloc, and freeing garbage may be literally free depending on the algorithm used. When an object falls out of scope in a reference counted world, it is typically immediately freed - if this is a handle into a large recursive data structure, for example, it can definitely suck up cycles. Counterintuitive as it may seem, GC can be the cheapest solution in some circumstances, unless your program eschews malloc entirely.
You're saying you have a different definition of "garbage collection", that's fine. Reference counting is listed as one of the three classical garbage collection algorithms on page 19 of "Garbage Collection" by Richard Jones and Rafael Lins. In the preface they define garbage collection as "the automatic reclamation of heap-allocated storage after its last use by a program."

It is irrelevant to cite situations under which an algorithm will fail to reclaim storage as evidence that an algorithm is "not garbage collection", since it is provable that situations exist for every possible algorithm. I can write a program that creates an infinite linked list but only ever uses the head, most GCs would fail to reclaim the tail of the list even though it is garbage.

This is not a theoretical concern, space leaks are possible under any automatic storage reclamation scheme.

Since in practice you can write applications for Android and iOS with languages and runtimes of your choice...

Kinda splitting hairs. Even though it's automatic, it's not called garbage collectio, and its handled quite differently in iOS 5 than in languages such as Java. iOS releases memory the instant its reference counter gets to 0 - not seconds or minutes later.

As you must know, the very name Garbage Collection implies an asynchronous process that travels up and down the program memory street at periodic intervals, trying to find garbage to collect.

The iOS model is more like a waiter in an expensive restaurant who comes and takes your plate away the instant the last morsel of food is in your mouth. You don't have to discard the plate yourself, but you can guarantee he will pick up your plate the moment its free to be picked up.

> I would consider ARC garbage collection

It's not, so you should not, because that's completely wrong.

Anything that runs in Dalvik VM has gc turned on and its mandatory.. even C programs that run in Dalvik, all androd applications run in Dalvik even c ones, have the Dalvik Vm gc turned on..thus quite mandatory on Android.