My application crashes when I navigate to different view for more than 10 to 11 times. I mean I have 6 buttons on main screen which on pressing bring you to different views. when I press these buttons repeatedly then my app crashes. I have spent 3 days but comes up with no solution. here is the code where app crashes
when i uncomment release statement then it crashes after first time.
-(IBAction) goToLiveAlerts{
teamAlerts *showLiveAlerts=[[teamAlerts alloc] initWithNibName:#"teamAlerts" bundle:nil];
[self.navigationController pushViewController:showLiveAlerts animated:YES];
//[showLiveAlerts release];
}
when i uncomment then i console error is
"wait_fences: failed to receive reply: 10004003
[Switching to process 2093]
[Switching to process 2093]
Program received signal: “EXC_BAD_ACCESS”."
-(IBAction)goToPhotos{
picturesGallery *showPictures=[[picturesGallery alloc] initWithNibName:#"picturesGallery" bundle:nil];
[self.navigationController pushViewController:showPictures animated:YES];
//[showPictures release];
}
Do you use ARC or not? If not, according to your code, there is some memory leaks in your code, try this:
-(IBAction)goToPhotos{
picturesGallery *showPictures=[[picturesGallery alloc] initWithNibName:#"picturesGallery" bundle:nil];
[self.navigationController pushViewController:showPictures animated:YES];
[showPictures release];
}
Anyway, you need to provide more code crash log.
According to your crash log, EXC_BAD_ACCESS means there is some memory leaks. Enable NSZombie in Xcode to debug. In Xcode 4.3, go to Product->Edit Scheme->Diagnostics and check Enable Zombie Objects.
Related
I have a question about iPhone develop
CarDetailDetail *myview = [[[CarDetailDetail alloc] init] autorelease];
myview.detailMaintainID = self.detailMaintainID;
[[self navigationController] pushViewController:myview animated:YES];
this is work fine in iPhone 4 (iOS 4.3) and iPhone 3gs (iOS 5.X)
but iPod touch (iOS 4.2) will crash when I pop back one or two times,
memory warning will appear and has bad access error
but when I not release *myview (remove autorelease keyword) , iPod works fine...
I don't know why , some one can help me? thanks
Experiment with the YES/NO flag on the pop animation
If you find that you are getting no crash on your problem device with NO pop animation it probably indicates a timing issue of some sort.
In other words a block or web thread is trying to hit a view controller which has been deallocated already.
post your your console logs in the question too for more help.
try doing this
CarDetailDetail *myview = [[CarDetailDetail alloc] initWithNibName:<name of view contrlle> bundle:nil];
//Remove this bit of code myview.detailMaintainID = self.detailMaintainID;
[[self navigationController] pushViewController:myview animated:YES];
[myview release];
I am doing memory leak testing. The tool indicates a leak in line 2 of the code below. What is the reason?
DailySales *ds = [[DailySales alloc] initWithNibName:#"DailySales" bundle:nil];
[self.navigationController pushViewController:ds animated:YES];
[ds release];
The code looks fine. Are you running in the simulator or on the device? Running Instruments on the simulator can produce false leak reports.
Objects loaded from the NIB are leaking. Check your outlets and see if they are carefully released in dealloc.
I'm having a strange problem with my UINavigationController. the stacktraces are:
which is very odd to me because all I did was:
CommonVC* cvc = [[CommonVC alloc] init];
//CommonVC is my customized viewController. and i did some setting after the init.
[self.navigationController pushViewController:cvc animated:TRUE];
[cvc release];
and after 3 times pushing and popping it crashes.
i also ran it with NSZombie but it told the zombie is the CommonVC itself.
so can anyone help me find where the problem would be?
Do you make use of delegates and set them in your view controller. If yes check if they are made nil...
Am all most done with my App.When am running the App on Simulator it works fine but when i run on the device for some time the debugger showing a message as "Program received signal 0".I tested the app with the help of instruments leaks it showing leaks.But am unable to figure out exactly where was the leak.Am releasing every object which am allocating.
For example am providing little part of my code:
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker=[[UIImagePickerController alloc] init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
// NSFileHandle *fileHandle = [[NSFileHandle alloc]initWithFileDescript
}
In the above code leaks are showing at the UIImagePickerController *picker=[[UIImagePickerController alloc] init]; but am releasing it.
Can some one provide me the detail information abt the leaks and how to fix them .Thanks in advance.
In this line of code:
[self presentModalViewController:picker animated:YES];
self (the parent controller) is actually retaining your picker and won't release it until the parent controller explicitly dismisses it. As long as your parent controller are dismissing this picker at some point in your code you'll be fine.
uiimagepickerview controller creating memory leaks in iphone - why?
Try to implement ui image picker view controller in your application & debug it.
You will find memory leaks in your application.
Why ui image picker view controller creates memory leaks.
-(void)addPhotos:(id)sender
{
if(imagePickerController==nil){
imagePickerController=[[UIImagePickerController alloc]init];
imagePickerController.delegate=self;
imagePickerController.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePickerController.allowsImageEditing=YES;
imagePickerController.navigationBar.barStyle=UIBarStyleBlackOpaque;
}
[self.navigationController presentModalViewController:imagePickerController animated:YES];
}
dealloc of my view controller.
- (void)dealloc {
if(PhotoDateArray!=nil)[PhotoDateArray release];
if(imagePickerController!=nil) [imagePickerController release];
if(objDetail!=nil) [objDetail release];
if(Picimage!=nil) [Picimage release];
if(mySavePhotoController!=nil) [mySavePhotoController release];
if(LoadingAlert!=nil);
[super dealloc];
}
Video link explaining how I am getting the memory leak in it..
http://www.yourfilelink.com/get.php?fid=508534
Even though you have the nil check, it's still possible to leak memory. I think what is happening here is that you are calling alloc / init multiple times, but only releasing once. My guess it that addPhoto: is wired up to some button click, dealloc would only be called once when the delegate is trying to destroy. This creates a situation like this:
button click
alloc / init
button click
alloc / init (memory leak on first alloc'd picker)
close window
dealloc (free second alloc'd picker)
A better way might be the way Apple does it in the PhotoLocations and iPhoneCoreDataRecipes examples:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
Then listen for the didFinishPickingImage and imagePickerControllerDidCancel messages to your delegate and a call to [self dismissModalViewControllerAnimated:YES]; in both places should suffice.
I dont know about the rest of the code, but do you ever have a release?
[imagePickerController release]
UIImagePickerController loads and initializes PhotoLibrary.framework the first time it is shown. This memory won't be reclaimed until your application is closed.
(the code you posted doesn't appear to have leaks as-is, but that doesn't mean it won't interact with the rest of your application in a way that causes them)
I can explain this because I was having the same problem.
Don't test memory on the simulator!
If you test the apple code on a device the memory problem disappears.
I was having a memory alloc leak which I found in Instruments. All I was doing was opening and closing the image picker (open/cancel) and using Apple code, my code and other people's code, just like yours above.
All were showing the allocation going up and up each time, as if the picker was not being released. If you tried to release it, it would crash (over released).
Then I found a really helpful web page which basically stated:
"This doesn't happen when testing on the device"
So I switched from the simulator and ran the tests on the device. Lo & behold there was no allocation increase and it behaved normally.
This however is totally evil and now we can place no trust in the simulator to do a reliable job.
I want to add this to save people, the time, pain and bewilderment of wondering wtf is going on!