What does the error warning: check_safe_call: could not restore current frame usually indicate? I've read in other places that it's a memory issue. Is it always a memory problem?
I'm getting this error on the device (not the simulator). NSZombieEnabled shows nothing. If I Build and Debug, my debugger window shows nothing. The peak memory isn't that high (3MB). It just crashes with the same error every time after scrolling around a map.
Any ideas how to debug this? Thanks.
Edit: I added the reason for my crash in an answer below (creating too many SQLite connections). If anyone else gets this error and finds their solution, please post it below. It seems like an error message with multiple causes.
I've seen this a few times, but never been able to actually pinpoint it to a problem outright. Although, the times I've seen it usually there has been some kind of infinite loop or recursion gone wrong and the debugger will catch it. I don't know if you've left it long enough, but after a while, the debugger should start to load the stack frames it does have and display them in the debugger window. There you should be able to see what is going wrong.
Like I said, usually when I've seen this its been due to infinite loops or recursion and the debugger will show upwards of 5000 calls to the same function, so finding the problem shouldn't be too difficult - but, saying that, it may not be the exact issue.
Just my two cents.
This warning also may happens when to use stack based block out of the scope the block defined without copying it.
http://developer.apple.com/library/mac/documentation/cocoa/Conceptual/Blocks/Articles/bxUsing.html#//apple_ref/doc/uid/TP40007502-CH5-SW2
http://www.friday.com/bbum/2009/08/29/blocks-tips-tricks/
I came accross this problem too but I found that it was caused by an image that was at too high a resolution. It would work perfectly in the simulator but not on the device. I resized the image to 320x480 pixels at 180 pixels per inch and now it works perfectly.
Hope that helps
I found the error in my code. It turns out that the SQLite database I was using was causing the crash. I was forgetting to close my database connection, and each time the code hit a particular function, I'd open a new connection. Eventually there were too many, and the app crashed.
It's looking like a lot of these errors are to do with a kind of overload (as Jasarien says).
Related
I'm making an iPhone RPG application, I was working on programming a CGPoint array to some sprites I wanted to add, but I didn't make any progress and thus deleted the code.
After this, an exception was thrown each time I ran the app' on the iPhone Simulator, it said it was to do with OpenAL, so I took all of the sound code out.
The project then ran fine on the iPhone Simulator, without sound though of course.
Now, upon taking all of my newly added code out, the iPhone Simulator crashes (freezes) when it's still on the Cocos2d load up screen and points to the following line of code in Xcode:
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");
I've been looking over my code with a fine-tooth comb for an hour now, checking in case I left any code in or changed anything, and I haven't.
Has anyone had any experience with this problem? Or can anyone give me an idea what might have happened?
Some light to shine on the OpenAL problem would be nice too (second time it's happened to me).
The best thing to do in situations such as these is put break points all over the place and look for the point at which the applications crashes from.
If you haven't yet check out the stack for any clues. Unfortunately if there is nothing on the stack or printed from the debugger this is really all you can do.
So I checked some other questions AGAIN, and found someone saying to restart the computer... This worked. It's annoying, so so annoying. But that's what worked.
Also, for any weird errors, just make sure you Product > Clean after adding/changing any resources you use.
This is kind of weird, but I noticed that up to 40 percents of the rendering time is spent inside glAlphaFuncx. I know that alpha testing is very expensive, but the interesting thing is I do not use it :) No single place of code uses alpha testing, neither do I invoke this function in any other way.
I also checked GL layer for blending on other sorts of stuff which might cause this to happen but it is what it is.
So, if anybody knows what might cause glAlphaFuncx to appear on the performance trace of CPU Sampler, I would be glad to hear it :)
Update: fixed the screenshot link: http://twitpic.com/2afxho/full
Update 2: the function that leads to invokation of glAlpaFuncx contains a single line:
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
Update 3: I tried setting the breakpoint inside this function, but it seems it haven't been invoked at all. I guess profiler is screwed up here...
It's weird that this function appears on a profiler trace, as you say you aren't using it. Try setting a breakpoint in glAlphaFuncx to see from where it is being called.
But anyway, that should not be a problem, glAlphaFunc will just set a state in the GL server side, it doesn't (or should) do any more processing than that. It shouldn't be a performance problem, maybe it's a bug in the GL implementation or in the profiler.
To be sure, you can disable alpha test with glDisable(GL_ALPHA_TEST).
From what I can see, glAlphaFuncx could just be taking the hit for setting up the rendering or pushing the pixels. It could be that it is run either first or last in the rendering.
Do you have an actual performance problem, or are you just trying to find pieces of code to slice off / optimize?
If so, you should set a breakpoint in glAlphaFuncx and see where it is called from and why. To do this, just bring up the debugger console and type "break glAlphaFuncx".
Have you tried explicitly disabling the use of alpha channels?
glDisable(GL_ALPHA_TEST);
http://www.khronos.org/opengles/documentation/opengles1_0/html/glEnable.html
Regardless of system, this sort of behaviour -- time spent presenting what's been drawn -- almost always indicates that the GPU is the bottleneck. Either you are drawing too much (if the framerate is a problem), or the CPU isn't doing enough (if the framerate is fine).
Actually, there's one other possibility -- that the amount of GPU work is fine, but the system is waiting for some kind of vertical retrace period. (That seems unlikely on a device that only ever has an LCD, and doesn't support a raster scan display, but maybe things still notionally work that way internally.) The upshot is still the same as far as the amount of CPU works goes, though, in that you've got time to do more stuff without affecting the frame rate.
I can't explain exactly why glAlphaFuncx specifically is appearing in the call stack, but if it doesn't appear ever to be actually getting called then I'd consider it a red herring until proven otherwise.
I've spent two days on this and I still can't find the cause of the crash.
I know it has something to do with trying to access an object that has been freed but I don't know which access or which object.
Whenever I google trying to find the source of EXC_BAD_ACCESS people suggest using NSZombies. The problem is when I enable zombies (either in xcode via environment variable or in instruments via ObjectAlloc properties) the program doesn't crash where it usually does and the zombies don't report anything (nothing shows up in logs and nothing is flagged in instruments). Is there something I'm missing with NSZombie?
I've tried utilizing some information from xcode's debugger and from ObjectAlloc in instruments but all the information is very cryptic and doesn't really help me.
I've set the debugger to stop on objective-c exceptions. When it does it this is the call stack shown:
0 objc_msgSend
1 ??
2 -[UITableViewCell removeFromSuperView]
3 -[UIView dealloc]
... etc ...
First of all, what's the deal with '1 ??' ? What do the question marks mean? Second of all how can I know where this was called in my code? All the operations stated are too generic (eg UIView dealloc, but which UIView? And where?).
Also when the exception occurs it points to assembly code which again, doesn't do me any good unless I was to spend hours trying to figure out what the code does. I know some assembly but there has to be a better way... right?
Is there any way I can get meaningful information as to what was the last line that ran in my code before the exception occurred?
I've tried sprinkling some NSLogs and breakpoints around but it doesn't help me much because the crash happens after I pop a view controller from a navigation controller. Everywhere I place breakpoints the breakpoints are reached fine (I can't find a point to break after the crash). It's only when I 'continue' in the debugger that the exception occurs. It's as if the crash happens outside of my code so I have no idea where to get a handle on it.
I've looked through my code and double checked that I adhere to all the memory management rules (at least to the best of my knowledge). I'm sure it's something very subtle but I can't seem to find it.
If anyone has any ideas how to find such bugs without NSZombie please share.
Thanks.
Well I found the problem. I had a custom table cell class in which I called [super dealloc] first in the dealloc method (rather than last). I guess I wrote this class in a hurry and didn't really think about it. I'm guessing something got released in the parent that the child needed for releasing?
So I don't have a real answer to my own question but basically I found the problem using a combination of ad-hoc code tracing and various debugging techniques (breakpoints, NSLogs, trying to decypher cryptic stack trace,etc).
Actually the main strategy that helped me was commenting out code bit by bit until I stripped down the problem area into as simple as it gets while still keeping the crash intact. This let me realize the problem wasn't where I thought it would be but in a more subtle area (eg in the dealloc method of a secondary class in this case).
I hope this can sort of help someone out. I'll leave this question unanswered for a bit incase someone has a more thorough debugging strategy without relying on NSZombies. Also if someone can clarify what those two question marks mean in the stack trace that would be helpful.
I have a UIViewController and I'm noticing that I've done something to where the didReceiveMemoryWarning method is getting called every time I run it on an actual device.
I've run the project with Run > Run With Performance Tool > Object Allocations (and Leaks also). There are no leaks but I have no idea how to read or understand the "Object Allocations" data that is displayed.
So ...
How do I read this information and what is/are the best ways to figure out (and resolve) why this is happening?
Thanks
EDIT:
I should mention that I also have a number of 3rd party libraries/code that I've included in my project (e.g. Three20, MGTwitterEngine, FTUtils, extThree20JSON and Twitter+OAuth). Could this be causing this??? Or at least contributing to the problem?
EDIT #2:
Don't know if this helps but I notice that this is happening either everytime that I present a UIImagePickerController modally -OR- after a take a picture using it.
* UPDATE *
Ran it again with the Object Alloc tool for several minutes and I don't see anymore than 4.75MB being allocated at any given moment. The app was running on a device and typically with 2.5 MB allocated on average.
Does this seem problematic to anyone??? Seems like its in an acceptable range insofar as I understand thing.
This may happen some time when your device have less memory free to use. Check your device free memory.
The problem had to do with UIImagePickerController ... and all is answered in this post: Received memory warning. Level=1 when showing a UIImagePickerController
I am getting a lot of strange EXC_BAD_ACCESS crashes on the iPad that only happen on the device and not in the simulator. I am assuming that they are somehow memory related, but I am not sure. They all happen with image context related functions.
One strange example is using CGImageCreateWithImageInRect. For example, if i run through a bunch of UIImages and crop them with CGImageCreateWithImageInRect, it will always crash at specific arbitrary sizes. Like, if I crop them all to 200x200, it crashes out after processing 12 images. If i crop them to 210x210, it works no problem.
The EXC_BAD_ACCESS happens inside of "memmove" called from "CGBlt_copyBytes". That is all the debugger shows me strangely enough. I can't see the callstack going up to any of my methods.
All of this works fine in the simulator!
I know this is all very vague, but if anyone has any ideas, they would be greatly appreciated.
Start by doing things like checking for zombies, and running clang (Build & Analyze) to see if you have memory management issues. I think you'll need to post more code, because this does sound like memory stomping.