How does the Instruments stop working automatically? - iphone

I try to monitor the allocation through Instruments.
However, when I run to a point, sending some jabber msg, the Instruments stop working automatically.
I wonder how does it stop.
Is there any code in an app could stop the Instruments?

I have faced this problem too. The answer i got was: Instruments does stop if your memory usage is too high. Turn on Allocations, and see the memory usage. In my app, I was calling web services, which were downloading some heavy data, because of which my app's memory consumption would go unto like, 60-70 MB, (for an iPad app). This was causing instruments to crash.
So I had to put some memory fixes. I was able to reduce it to around 12 MB. And then Instruments resumed to work fine. Hope it helps.

It could also be as #Cory Kilger suggests and the app is crashing.
Try running it outside of instruments.
Good luck :)

Related

Phone gets heated when running my application

When I use my application for awhile, I have noticed that the device gets hot. Apple devices usually get hot when running applications, so I want to know if there's a method to check if I have done something wrong in my application.
I don't think the Allocations tool in Instruments could help me diagnose the problem.
Instruments can definitely help you solve this. Your device gets hot as a direct result of intense CPU activity, which Instruments can track and show you your CPU usage and memory allocations.

Query about memory management in iPhone

I have query regarding memory management for iPhone app.
I have a app in which is also build in for android app as well.
Now we have same functinality and same variables but due to some bad memory management the app gets crashed for iPhone (after 20 - 25 min) and on Android it works perfectly for much longer time without crashing.
In android they have garbage collector but for iPhone sdk we dont have anything like that, so I'm a bit confuse how to proceed.
I have released all the memory allocations in didReceiveMemoryWarning and also in dealloc.
Fisrt you have to find the memory leak. so run the app in debug mode or using instrument first find the problem and update here. and important thing if you get EXC_Bad_Acc means you have to enabled NSZombieEnabled for further detail give me a comment
Before you do what #maheswaran suggests, run the analyzer to determine if you have any easy to find (for the analyzer) memory problems.
Also, it would be good for you to put some time aside and read about how memory management works on iOS.

iOS Development: What are some ways I can troubleshoot a lag issue in my game that occurs 15 - 30 minutes after playing it?

I'm building an iOS puzzle game to become familiar with the platform and a few of my testers are noticing a severe lag issue that occurs intermittently about 15 to 30 minutes after playing it and the lag doesn't appear to be associated with any specific part of the game. I've tested the app using the Leaks instrument and havent found any leaks yet.
What are some things that would cause a game to instantly begin to lag after playing it for a while?
What are some methods/tools I could use to troubleshoot the lag?
Thanks so much for your wisdom!
UPDATE: As a new iOS developer, I was under the impression that the Leaks instrument would report at least most of my memory leaks, so I was very comfortable believing my app was managing memory properly when no leaks were reported. Not the case! After following a few of the suggestions posted here, I watched a few videos on how to use the Allocations instrument and found that my app was losing a TON of memory over time and, after spending about two hours walking through ALL my code and fixing memory-related code, my game is no longer lagging or reporting any lost memory or memory leaks. Thanks, all!
The main thing would probably be a memory warning, which would in turn cause a bunch of game assets possibly to be freed all at once...
Instead of leaks, the place to start is the ObjectAlloc tool. Leaks only shows you memory used your application already knows about. ObjectAlloc shows you the total memory used, and the real issue would be seeing the graph of memory used climb over time.
Lastly, I would try to get the game into that state while using the TimeProfiler instrument, so that you could see what kinds of operations took up a lot of time suddenly when the game slowed down. You have to do that on device, it will not tell you what is really going on using the simulator.
check to see if you are getting a memory warning. also, try using the heap shot tool in instruments, as something could be holding on to a reference, and stopping objects from deallocating, this doesnt show up as a standard leak.
i would definitely have a look at the object allocation tool, and keep an eye on objects still living.
if you haven't used instruments much, I think apple have some videos up on the dev site going through them.
Are you using leaks with the simulator or with an actual phone? I have found the simulator to have different results than a phone when running leaks. Based on your description it sounds like you have some leaks occurring.
I have had some similar feedbacks while battery runs low. So, you can check, does issue reproduce when device is powered, or not.
Also, do you use openGL in your game? I'm asking because i've observed some lags with first-time appeared textures drawing, although these textures were previously preloaded and cached.
And last question, what devices your testers are working with?
LEAKS are NOT the same as excessive memory allocation.
It sounds like you are just not releasing things that don't need to be around anymore and you're maxing out on memory and chunking.
Check your allocations and keep an eye on what keeps expanding when it shouldn't.

Game crashes on the actual iPhone but simulator? memory problem?

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.

How to detect memory leak / battery drain in an iPhone app

I'm afraid I introduced a memory leak or something to version 1.2 of my iPhone app. When I use 1.2 version I notice that my battery drains a lot quicker then with 1.1 version. For comparison, with 1.1 version the battery would last whole day and still have plenty of juice in the evening but with 1.2 I find that I have to plug it in mid afternoon.
Would a memory leak (or a lot of them) cause an increased battery drainage, or do I have something else going on?
The only interesting thing my app uses is AVAudioPlayer class to play some caf audio files. Other than that it's just couple of views with a table view.
I do call AudioSessionSetAcvie(false) in my applicationWillTerminate method, so I don't think it's the audio session that's causing this. I don't have to have my app active for the battery to get drained. It's enough to use it for a while and then exit. So I'm pretty sure I'm leaving something behind, I'm just not sure what.
I tried playing with Instruments tool, but it looks like you can't used with the app running on the device (for some reason my app stopped working in the Simulator)
Any ideas on how to go about finding what's causing the battery to drain?
Memory leaks will not cause increased battery usage. However, if a memory leak persists, eventually you will get a memory warning, and if you can't clean up enough memory, your application will be killed.
Increased battery utilization usually means something is causing your code to continue running. The best way to tackle this problem is to run your application under Instruments (with Sampler probably) and let it sit there in the state that you're confident it usually runs the battery down. Inspect the results of Sampler, and if you have code running, you'll be able to see the stack trace for it.
Hopefully once you've located what code is running, it will become apparent how to stop it.
Memory leaks won't cause increased battery usage, as Nilobject says.
I would try commenting out various areas of functionality, one at a time, to try to narrow down the area that is causing the problem. In your case, the first thing to try is obviously to remove the audio. If, once you've done that, battery usage is back to normal, you know where to look more deeply.
(for some reason my app stopped working in the Simulator)
I would fix that and use instruments to fix the performance bug. It's never a good idea to fix the difficult defect and leave the easy one.