Strange errors
Any idea what might cause a "double free" error? And does anyone know if a CALayer has a fireDate method or not? I can't find it in the documentation.
double free is definitely a memory issue try stepping through your code with GuardMalloc.
kodex Wrote:double free is definitely a memory issue try stepping through your code with GuardMalloc.
Hmm, well, call me a newb, but I don't know what GuardMalloc is...?
Double Free is when you free something that's already been freed, as the name suggests 
Xcode has a "Run With -> Guard Malloc" command which may turn out to be handy

Xcode has a "Run With -> Guard Malloc" command which may turn out to be handy

Talyn Wrote:And does anyone know if a CALayer has a fireDate method or not? I can't find it in the documentation.
fireDate is only available in NSTimer, and CALayer does not inherit from NSTimer, so no. You can hold down the option key and double-click on any method in your code to get a quick search for it in the docs BTW.
OneSadCookie Wrote:Double Free is when you free something that's already been freed, as the name suggests
Xcode has a "Run With -> Guard Malloc" command which may turn out to be handy
Well, that's kind of strange, because when I release something that has already been released to a 0 retain count, it gives me a EXC_BAD_ACCESS error, not a malloc error. Ah! What does Guard Malloc do, out of curiosity?
Oh yeah, and another thing

Yeah, that's why I'm confused. I keep having my app crash because it says "unrecognized selector sent to instance... [CALayer fireDate:] NSException." Also, the Research Assistant is AMAZING. Open that by Ctrl-Shift-?, it has quick references to what you're typing, links to the docs, and even sample code references. Best feature in XCode yet.
Don't call methods that don't exist or it will throw an exception! You need to pay close attention to your warnings, and perhaps even treat warnings as errors so that it forces you to deal with them before you get to play.
I think Research Assistant is neat, but is generally not very useful to me and clutters my workspace, so I prefer to option-double-click to quickly jump to documentation when I need it from time to time. command-double-click is equally (if not more) useful because it sends you to the declaration in the appropriate header.
I think Research Assistant is neat, but is generally not very useful to me and clutters my workspace, so I prefer to option-double-click to quickly jump to documentation when I need it from time to time. command-double-click is equally (if not more) useful because it sends you to the declaration in the appropriate header.
AnotherJake Wrote:Don't call methods that don't exist or it will throw an exception! You need to pay close attention to your warnings, and perhaps even treat warnings as errors so that it forces you to deal with them before you get to play.
I think Research Assistant is neat, but is generally not very useful to me and clutters my workspace, so I prefer to option-double-click to quickly jump to documentation when I need it from time to time. command-double-click is equally (if not more) useful because it sends you to the declaration in the appropriate header.
It's not me! We have not code that calls that method in the CALayer. I have no idea why it's being called. The only thing I can think of is there is some side effect to all the animations we have, but if that is the case, it's Apple's fault. I don't even know where to start debugging this one. I'm probably going to have to follow the stack for the next couple of hours (or days...) to watch where this unrecognized method gets called

Hmm... Well if you aren't calling the non-existent method then perhaps it is the OS that is calling it, and it is calling it an unrecognized selector because it is calling it on an object which has already been released? Impossible to say for sure what is happening on the system's side of the fence, however:
Neglecting to retain an object or inadvertently releasing one is the root of probably 75% of all the mystery bugs and memory issues I've ever had with Cocoa. One quick way to help confirm this is to add a retain to your suspected object.
Neglecting to retain an object or inadvertently releasing one is the root of probably 75% of all the mystery bugs and memory issues I've ever had with Cocoa. One quick way to help confirm this is to add a retain to your suspected object.
You could try enabling zombies (add NSZombieEnabled with YES to your environment variables), set a breakpoint on objc_exception_throw, and then run in the debugger. That should stop you when you try to message the dead object.
Ok, Guard Malloc brought up a fatal error with this error code:
dyld: could not load inserted library: /usr/lib/libgmalloc.dylib
This suggests that the lingmalloc library is not linking properly (to the best of my guesses). Any ideas on how to solve this issue?
dyld: could not load inserted library: /usr/lib/libgmalloc.dylib
This suggests that the lingmalloc library is not linking properly (to the best of my guesses). Any ideas on how to solve this issue?
Are you doing iPhone dev? Who knows if guard malloc works there. NSZombieEnabled probably does, if you can figure out how to use it.
Your two bugs could well be related, the double free and the message being sent to an unexpected object.
Your two bugs could well be related, the double free and the message being sent to an unexpected object.
That is the Guard Malloc library, see; http://developer.apple.com/documentation...loc.3.html
OneSadCookie Wrote:Are you doing iPhone dev? Who knows if guard malloc works there. NSZombieEnabled probably does, if you can figure out how to use it.
Your two bugs could well be related, the double free and the message being sent to an unexpected object.
That's what we figured. But, of course, the malloc error being so damned elusive, it's going to be hard to tell until it's fixed.