iPhone known memory leaks - list - iphone

Is there a list of known leaks within the iPhone SDK sitting somewhere, all alone?
I guess you would have it specified by version. (I just ran my test app - it has a leak outside the project itself (somewhere related to connections) when testing it on a v3.3.1 iPhone 3G, but the leak is not there using an iPhone 4 v4.0.2.).

It's doubtful that there's a public list of known memory leaks. If you want to know whether your leak is a known issue, your best bet is probably to search Open Radar, or to use Apple's Bug Reporter and see if you get a response.

During my short experience with the iPhone SDK, I have never encountered a memory leak caused really by the SDK. It is mostly caused by your code but has shown itself later.
It is also possible that the new SDK has improved some ways of doing things, so that your previous leaks do not occur anymore.
You need to give more details to the leak in order to help you.

Related

Cannot find memory leak, possibly due to SwiftUI

Problem
I profiled my app and found that I have memory leaks. Unfortunately, I'm unsure how to diagnose it in this case.
Here is what the memory leaks show in Instruments:
Question
It says that the Responsible Libraries are system libraries, does this mean that this leak is a bug, or is it on my part?
Is my app somehow causing this leak?
If so, what could possibly cause it? I don't want to post all my app code making for an unreasonable question, so help for where I need to look would be a great help.
I have added tags for Swift and SwiftUI because it looks like the leak is coming from SwiftUI shown in Instruments.
There is a bug in SwiftUI which causes Memory Leak as of Xcode 11 Beta 3. You can also verify this by building a simple app which shows just “Hello World”, the instruments show a leak here also.

Memory management in IOS application

I am developing an IOS application and i will submit it the next week the Apple store. but i am not very good in memory management.
I would like to know what are the all tools that you use to remove all the memory erros ( leaks,...).
should i remove all the NSLogs before submit it to the store ?
What are the other things to take care before submit it to the store ?
thanks for your answers
Before submitting to the app store..
Detect all leaks, you can use
a) Leaks (xcode->instruments->leaks).
b) Static analyzer tools, if you are using newer versions of xcode (Build-> build and analyze).
c) Above all , make a thorough check yourselves, that you arereleasing all memory that you are allocing/retaining..
What the need of NSLog in a
distribution build. NSLog helps in
debug..Remove them all..
Run your app in whatever iphone
device you get..Never submit an
iphone app to store without checking
on device itself.
If your app crashed during review,
then it is surely rejected. Resolve
all bugs/crashes before submitting.
A good QC on device is a must.
This checklist might be helpful..
The static analyzer and the instruments will help you detect the leaks. Find and resolve them. Have a look at Memory management it will help to resolve leaks.
In Xcode , Instruments -> Leaks, is used basically to find out memory leaks.
Hope this helps you.

XCode building: identical configurations behave differently

I have a superweird problem:
I get a crash (EXC_BAD_ACCESS) when running my app with Release as active configuration on my 3.1.3 iPhone 3G. (works well in debug configuration or in simulator , works perfectly on device running iOS4).
My first guess was one setting in the Release configuration was erroneous/missing. In order to test it I just made a duplicate of my debug configuration and surprisingly I get the same error (although configuration is just a copy of the one working).
I don't understand why, with configurations that are supposed to be the same, one is working and not the other one.
If someone want to enlighten me, I am banging my head against the wall.
Thank you
NOTE: base SDK is 4.0 and deployment target is 3.0
Perhaps you have an unassigned local variable. Object-C follows how C does this. So in a release version you cannot assume that any local variable is initialised to 0 whilst in debug you can (in this case I would guess a pointer).
EDIT:
Pass -Wuninitialized to the compiler (or better -Wall) for the compiler to warn on these Apple gcc man page Note only works if optimizer is on.
You should check for memory leaks and handling of memory warnings. The amount of memory is probably the biggest difference between the environments you quote.
In another scenario I once found out that the simulator was faster, and therefore a certain race condition didn't show up, which did show up on the device. That's the second difference in the environments you quote: speed.
Try to pinpoint your crash and investigate from there. NSLog all didReceiveMemoryWarnings. Look for places where you made assumptions, i.e. about static information.
I fixed the problem.
It was three20 library fault. I had updated to the master branch that support iOS 4 but unfortunately this breaks support for 3.1.3. (thing that is not documented apparently)
Anyway I found this post that helped me to spot the problem. I just had to apply this patch and then I was able to run my project on 3.1.3 devices and iOS4 ones
Weird thing: why was it crashing when I was initializing a UIActionSheet (on a line of code not related at all with the Three20 lib)?
Thank you for your help.

Tips and Tricks to avoid iphone app crash

Is there any tips to avoid crashing of iPhone applications. Sometime it is very difficult to understand where the problem is.
What are the possible reasons of iPhone app crashes ?
One of the biggest causes of crashes on the iPhone platform is not following the Cocoa Memory Management rules.
See this question: Memory Management in Objective-C
Crashes are caused by bugs in your code. To prevent these you need to:
(a) learn how to write robust code
(b) learn how to test your code (with particular attention to stress testing)
(c) learn how to debug
This is not specific to the iPhone-platform, but what helps a lot is catching (proper) exceptions and logging the exceptions-messages somewhere so you know what went wrong and don't only get a "force close"-message with little or nor further information.
you should add NSZombie class to your project to avoid EXC_BAD_ACCESS errors... even this helps to understand what's happened. So to do it you should click on the Get Info of your Executables and then go to the Arguments and there you can add NSZombieEnabled with value YES and MallocStackLoggingNoCompact =1

iPhone: iPhone application testing

First, Thanks to all for your quick help for any questions asked in this forum.
I just want to know what are the testing tools coming up with Xcode on Mac as i need to test my iPhone application professionally (or) What do you suggest to use debug and test my application using any (or) built-in tools?
Thanks.
The first thing I try is Xcode's "Build and Analyze" menu command.
Next thing is to run Instruments and look for memory and object allocations and disposal. Instruments should keep you busy for quite a while as it can provide you a wealth of information, including network performance and graphics utilization.
When using instruments, the first method you should check is memory allocation and leaks. When your application leaks, it will spike. Click on this leak and then extend the details to find the exact whereabouts of the leak.
However read the documentation on it all first.
Documentation