views:

566

answers:

5

So, I finished writing my first iPhone App, and I have sent it out to a group of beta testers. Everybody is happy, except for this one guy who noticed that after having run my app, another app is not starting up anymore.

Not knowing too much about memory management, I started looking at the Leaks graphs in Instruments, and noticed, that there are some leaks going on in my app.

Three questions:

  1. Are leaks always bad? The biggest leak is 15k on a total of 5,1 MB allocated memory.
  2. Will Apple refuse my app because of leaks?
  3. Is not all the memory automatically freed up as soon as my app quits? Could it be that my leaking app is harmful to other apps?

Thanks Sjakelien

+3  A: 

Any leak that persists beyond the exit of your application is an OS bug, and hence Apple's problem.

It would be unfair to reject your app on this basis.
I don't know if that's any comfort to you.

For the record, my app provokes a leak in mediaserverd.
The leak is a tiny bit smaller in the 3.0GM.

Another incorrect usage of an API crashed mediaserverd.
Also 3.0GM. Nasty. I'd have preferred an error code, however
this could theoretically be used to work around the leak.

Rhythmic Fistman
mediaserverd isn't very careful with its inputs. The worst I've been able to do is eat CPU and cause a buffer loop (effictively killing all audio/vibration until the user reboots the device). There's also the capability to schedule audio long after your app has closed. Encountered any other nasty crashes?
rpetrich
Two crashes (1 on 2.x, 1 on 3.0), 200k leak on 2.x and 200bytes on 3.0. It's garbage.
Rhythmic Fistman
+7  A: 

Each app is supposed to run in its own "sandbox," and is by design not supposed to affect any other app installed on the phone. If your reviewer found a case where your app really did affect another app, that's definitely not your fault, although I'd love to know how that was accomplished ;).

My guess is, though, that your reviewer's other app broke completely independently of your app, and he/she is spuriously attributing the fault to your app. Ask him to try to reproduce the problem (uninstall both apps, install the other app, install your app). If it's reproducible, some iPhone hackers may be knocking down your door to figure out how you did it! I would bet lots of money it's not reproducible though.

Matt Bridges
You don't have to look too far to find bugs in iPhoneOS. The "iPhone hackers" can start here: http://openradar.appspot.com/search?query=iphone
Rhythmic Fistman
To reproduce the bug, I would say just restart the device, run your app and then check if the other one is broken (or restart and then run the other to see if it works anyway)
Dimitris
+4  A: 

what the other two answers say i agree with, however nobody has answered the first question ("Are leaks always bad") directly. i would say that yes they are. it's true that your program can possibly run with them for long periods of time without issue. and the OS should clean up the memory after termination (unless there's a bug in the OS, as said before). but eventually the leak will become an issue for someone at some point when they run long enough. also, even if it doesn't become an issue, it's probably a best practice to always fix memory leaks that you know about.

davidivins
+1  A: 

It depends on what "memory" you are leaking. Are you using device storage space to cache something? In theory then it's possible that you've used up enough space the other app cannot start because it needs a certain amount of free space.

If we're talking physical memory, then no. When your app is dead it is dead. You could ask them to restart the device and see if they have the same issue.

Kendall Helmstetter Gelner
+1  A: 

Apple does approve apps that have memory leaks.

That said, we thoroughly check that none of "our code" leaks before submitting to Apple because users don't like having an app suddenly shut down on them. I say "our code" because there are memory leaks in the framework that are not your doing. Thus Apple approves apps with memory leaks.

Also, I am doubtful your app has adversely affected the user's other app. I have not seen that behavior.

dredful