Two questions. All of a sudden, not sure why, maybe I hit the incorrect hot key, but my Object Library for .xibs in IB now shows NS items used in Mac development and not my typical iOS elements. How do I bring that back?
Second question, if I run an app in the simulator and it says in the console:
Received memory warning.Level = 1
What should I start with in troubleshooting? This is on an old 3G iPhone. Thanks!
regarding your second question: you should start troubleshooting your app for an excess of memory allocation and, if you can, look for memory leaks
maybe you want to look at this topic: iPhone OS Memory Warnings. What Do The Different Levels Mean?
For the first question: restart XCode.
For the second question: If the warning is infrequent and your app is not crashing, don't worry about it. Regardless or warnings or not you should be doing memory testing for leaks and also make sure your app responds to didReceiveMemoryWarning notifications. These warnings are normal and vary greatly depending on what other processes are running.
Related
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 made an iPhone app that uses camera. It works fine in iPhone, no memory warnings at all. It is also running on iPod touch 4G but gives memory warnings and crashes after some time after getting level 2 warning.
If someone can point me the possible reason for this. Thanks.
The only way you are going to fix this is by being able to debug it on the device. I wrote this blog to explain how to debug EXC_BAD_ACCESS, which is what I assume you are getting
http://loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html
The simplest things to do:
Run a Build and Analyze and fix every problem it finds (or at least rewrite it so that B&A doesn't think it's a problem) -- Having a clean B&A is a really good way to making sure you catch these problems early
Turn on Zombies and run your program -- this makes the last release sent to an object turn it into a zombie rather than dealloc it. Your program will leak tons of memory, but if you ever send a message to a zombie it will stop right there and you will see a bug that you need to fix, because in your real version, that would be a crash (sending a message to a dealloced object).
More techniques described at the link
It crashes on a specific operation or randomly?
if randomly,
use instrument to check your memory leaks and memory usage. It's hard to figure out where the problem lies in without going through all your app.
I have implemented pdf reader application for ipad.Its working fine in simulator.But its terminated in device with exit status 10.I done know whats happning.Please help me solve this problem.
Thanks in advance.
John,
Most likely it is a memory leak that is causing the app to get killed for consuming too much memory. Run the app with the Leaks tool (in the Run menu of XCode) and check how much memory gets allocated on load or during use.
Try it on the simulator first since you said it won't work on the device. Also, be sure you are releasing all objects you create after using them (but only the ones you create, not the ones Apple does).
A good reference guide to memory management: http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/MemoryMgmt/MemoryMgmt.pdf
I've had lots of problems getting a simple UIImagePicker working (see my other posts), and I've been getting memory warning notifications after taking a picture and before I even get a chance to dismiss the UIImagePicker
Now, however... I've loaded up my app in Xcode today and all is working fine. Can't get the memory warning at all, under the same build settings etc.
My question is.. is this normal? Perhaps it was cleared by an iPhone restart, or XCode restart. Or should I be worried that I've still got a hidden memory warning, only now it's hiding from me?
Thanks!
yes, very normal. memory is used by lots of background tasks on the phone, so it really depends what your email client is doing, whether you're installing apps in the background, and lots more.
It also depends a lot on the device you're testing on too. For example, if you're testing on an iPhone 2G, you'll have a significantly lower amount of memory to play with than if you were testing on a 3GS for example.
Depending on what kind of requirements your app has, and what choices you're making in terms of what to target (3.0 only? 3G upwards, etc) its best to always test on the least capable device so that you can get an accurate idea of how the app will perform on that device.
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.