开发者

Is any memory leak in iOS accepted at all?

I am new to Objective-C (coming from Java) and I think I am getting a pretty good understanding of memory management. But when my app loads, I get a extremely small memory leak, that only occurs when the game is loading (we are talking about 32 to about 512 bytes).

It's random when it leaks, and it doesn't seem like it's the user that triggers the leak. Normally it is detected after about 20sec to 1min.

The information I get from the debugger is never the same. Sometime it's UIApplication thats "responsible frame", sometimes it's [UIWindow makeKeyAndVisible] and sometimes it's [UNibDecoder].

Is this bellow a "accepted" limit, or should the app not leak at ALL? This is my first "big" app. I have done a minor flipsideview app, and there where no leaks what so开发者_开发知识库 ever..

On the other hand, what is the best way to identify leaks?


It's not great, but it won't get your app rejected unless it causes a crash in front of a reviewer. The size is less important than how often it occurs. If it only occurs once every time the app is run, that's not a big deal. If it happens every time the user does something, then that's more of a problem.

LLVM's static analyser can find some of these problems for you. Clean your build, then select Build and Analyze from the Build menu. There's also a Leaks template in Instruments.

It's probably a good idea for you to track down these bugs and fix them, because Objective C memory management is quite different compared to Java, and it's good to get some practice in with smaller stuff before you're stuck trying to debug a huge problem with a deadline looming.


Too much total live memory use is what will cause your app to crash and/or get rejected. If you leak memory inside a loop or repeating method, the leaks will eventually add up, and your app will crash.

But if there is a leak, but not in a loop or repeating process, and the total amount is less than typical memory usage for an app, then it might be impolite and inelegant, but there's really no way to tell, and there's very little operational downside.

I often stress test my apps by purposely "leaking" several megabytes during app launch, and making sure the apps still run OK. Some of these apps have gone on to be approved for App store distribution with this leaking test code still accidentally left enabled (mia culpa!). But that shows that even a few MB of leaks is not a problem for app approval (unless that's enough to make your app crash during low memory testing).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜