I have run my app with instrument and i m getting a memory leak but i dont know at which point that memory leak is happening.
How will i know at which point memory is leaking.
Check out this article "Actually finding a memory management error with Instruments", from the big nerd ranch. Creating "heapshots" is a good way to start narrowing down the code parts that show no obvious memory management errors at first glance. But as ACB stated already, if a system library is leaking (rare case) there's not much you can do about it. But most of the time the memory issue is always in your apps' code somewhere! :-)
It says responsible library is quartzcore, and it is only 16 bytes. As long as it is not in the app and the OS is causing the same, you cant do much about this. I would recommend you to ignore this.
If you are facing issues, check the allocation tool -> Live bytes section and check if memory is shooting up when you are selecting a lot of images at the same time.
I can see from your screenshot that your app is already running in your device/simulator and you are trying to run it again with instrument, try to close your app completely from device and then start it again with instrument.
You can read more details about Xcode instrument from Apple.developer InstrumentsUserGuide
Also I have found another good tutorial about this in Raywenderlich blog
Another good documents is here
Related
My app crashes several times without any error or stack trace on my console. Then the only way left is to go and check Apple's crash reporter. I found "jettisoned" next to my app name, which in turn implies iOS killed my app, but how do I figure out why did it happened? Why is iOS killing my app? Initially, I thought it was a memory overflow issue, but then, using Instruments, I figured out that my app was taking hardly 4-5 MB of memory, so I discarded those issues. Apple's doc does not mention much about this. Any help or suggestions would be highly appreciated.
It means the process was terminated because iOS needed memory:
Memory usage of each process is reported in terms of number of memory pages, which as of this writing are 4KB each. You will see "(jettisoned)" next to the name of any process terminated by iOS to free up memory. If you see it next to your application's name, that confirms the application was terminated for using too much memory.
Documentation
I would take a look at that technical note for some additional help. The documentation also points out the Instruments does not measure graphics memory use, and that requires special handling.
I am new here . Sorry if I this question is being repeated but I have a slightly different issue than the others.
My app crashes randomly after certain amount of time interval without any error logs or stack trace. I suspect it's an memory issue . I have the following questions :
1.) How to get stack trace (I have tried NSZombie enabled and NSUnacughtExcpetion handler) but didn't worked
2.) I get Memory warning frequently in my app. How do I confirm whether it's the prime suspect for the above issue? (I have used Leaks, my app crashes when it has just 4Mb usage so I am not quite sure whether memory leak is causing it my app to crash. I know certain application which take heap memory more than 4MB .)
3.) What is the upper limit for Memory leak for an application in iOS before app crashes ?
4.) Would ARC help me in this situation ?
Also, I have tried to debug issue using NSLog statements but since it crashes randomly , it would be hard for me to detect the root cause using this technique.
Any ideas would be or help would be really appreciated
My app crashes randomly after certain amount of time interval without any error logs or stack trace. I suspect it's an memory issue.
To confirm that it's a memory issue, sync your device with iTunes,and look in ~/Library/Logs/CrashReporter/MobileDevice/ for a files with LowMemory in their name. If you see (jettisoned) next to your app name, that confirms it was killed by iOS for using too much memory.
The only other way an app could exit without leaving a crash report is if it erroneously called exit().
For more information, see "Debugging Deployed iOS Apps", and "Understanding and Analyzing iOS Application Crash Reports".
Not sure but reading the registers might help.
First go to Exceptions tab and 'Add Exception Breakpoint' using the + at the bottom left corner.
Then when the app crashes click on "0 objc_exception_throw" under Thread 1
Finally in the console enter:
register read
(you should get a list of registers)
po $rax (normally the exception is in 'rax')
(you should see the exception output on the console)
Hope this helps.
That does sound like maybe the device is running low on memory and shutting you down. There's lots of threads on stackoverflow on debugging memory warnings.
This one talks a little about what to look for when using the Instruments tool.
Here is an explanation of how to get the memory warning level, and what the codes mean.
There is no fixed memory limit on iPhones. I've asked Apple support representatives this question, and they wouldn't give me a fixed answer (probably because the algorithm does not actually enforce any one hard limit for a 3rd-party app).
And, yes, ARC can be a wonderful thing. In your situation, you might have to rework a lot of code to make it all ARC-compliant, but ARC is definitely a useful feature, and can produce programs with fewer memory problems, with less work by the coders (leaving you more time to fix other problems!)
I recommend instrument
https://developer.apple.com/library/mac/#documentation/developertools/conceptual/InstrumentsUserGuide/AboutTracing/AboutTracing.html
In my case i closed all other apps and it started working normally, maybe it was a memory issue
I have an iPad app that is doing really well, zero crashed reported by Apple after 5 months and 3 releases.
However occasionally the OS kills the app, my guess is for shortage of free memory.
I am not doing anything right now in the warninglowmem event.
I would like to receive some solid recommendation of what I should do to improve the memory footprint. What tools and tricks I can start using to understand where I am right now and how further I can go with the improvements.
I'd suggest starting by reading about Instruments which will let you see what memory you're using and how much. In particular, the "Quick Start" and "Analysis Techniques" sections in that document should get you pointed in the right direction.
Using the "Allocations" instrument will help you watch your memory grow and tells you where it's being allocated.
You might also try using the "Leaks" instrument, which will point out if you're leaking memory (rather than just allocating too much).
There is an awesome instrumentation tool included with Xcode that lets you look for leaks. From the Run menu choose Run With Performance Tool -> Leaks and you can see where you might be leaking memory over time. That's a great place to start. Next you can look at the "Allocations" tool to see how you're utilizing memory over time. Start there and you'll learn a ton.
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:
Are leaks always bad? The biggest leak is 15k on a total of 5,1 MB allocated memory.
Will Apple refuse my app because of leaks?
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
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).
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.
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.
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.
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.
I have built my first game using Cocos2D. It worked fine on the simulator. But when it runs on the actual iPhone, it crashes. I don know why. Thought it was memory leaks, so i tried to detect, but no leaks found. I tried to increase and decrease frame rate, neither both succeeded. Anyone experienced please help me out. I am really stressed now. If anyone had the same issue please share with me your opinion.
Yours thanksfully.
I've run into similar issues (I also use Cocos, but I don't think this is Cocos specific). The best thing to do is plug-in your iPhone and watch the stacktrace when it crashes (or retrieve the stacktrace after the fact)
This happened to me a lot because the resources between the iPhone and the simulator were not in sync; in other words, some how resources would be available to the simulator (eg: images) but those same resources were not transferred to the iPhone for whatever reason. Sometimes, if I ran 'clean' on the simulator, I would observe the same issue.
It's extremely frustrating to debug these types of issues, but you'll get used to it.
I agree with Dominic - we definitely need more information to be able to help you - do you have the output from the console or the stack from the debugger?
Also, while memory leaks are a Bad Thing, they rarely lead to crashes directly. They will increase the amount of memory used by your app so if you're memory intensive then you might get a problem but they're not the first place I'd look to try to debug this.
Try running the app in Instruments and watch the memory usage graph - then not only can you see the total that your app is using but you can get an idea of which sections of your app use the most and can focus your efforts in reducing it.
Sam
Sorry, but you need to specify more details. How does it crash? What does the error log say? One thing you might look into is the amount of memory, your game consumes. If it uses more than 64 MB on the actual device, the OS will very likely just terminate it. In the simulator on the other hand, your app might use lots more memory without a problem.
I have found tools like Instruments and NSZombieEnabled to be very helpful in tracking down issues such as these.
Without more information, I would try the following steps:
Delete the app from the device and simulator (using the tap-and-hold technique to make your icons jiggle) and reinstall it. Sometimes a setting (or lack of a setting) in the user defaults will cause a crash, and those don't get wiped out unless you delete and re-run your app.
Also try the "simulate memory warning" option in the simulator and see if that gets it to crash.