Question

I've been using this code to create my UIWindow

UIMyWindow* win = [[UIMyWindow alloc] 
                   initWithFrame:[[UIScreen mainScreen] applicationFrame]];

UIMyWindow isn't anything special it just has a pointer to a C++ class that does some wrapping of ObjectiveC.

Recently my application start crashing after adding some line of code that doesn't have to do anything with the error. The line of code that I added is just allocating a C++ object but the program execution never reaches this line.

Interesting enough my code works in Release.

My only guess is that I made some memory corruption on a completely different place. My questions are: What type of memory corruption that can be? And is there some good practices to track them down?

Was it helpful?

Solution

You certainly have a message that is send to a deallocated object.

You should try to debug your program with Instruments.app. It should show you the potential memory problems.

Also take a look at the NSZombieEnabled environment variable. Basically, it leaves a dummy object at the place of the deallocated object. You'll be alerted when a message is send to that dummy object, allowing you to see where the problem is located.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top