Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 11-12-2008, 01:21 PM   #10 (permalink)
johnqh
Registered Member
 
Join Date: Nov 2008
Posts: 812
Default

Quote:
Originally Posted by simsimma View Post
I think so, here is the code:

Code:
-(BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject

{
	
    if ( (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
		
		|| (delegateObject == nil) || (controller == nil))
		
        return NO;
	
	
	
    if(imagepicker == nil){
		imagepicker = [[UIImagePickerController alloc] init];
	
    imagepicker.sourceType = UIImagePickerControllerSourceTypeCamera;
	
    imagepicker.delegate = delegateObject;
	}
	
    //picker.allowsImageEditing = YES;
    // Picker is displayed asynchronously.
	
    [controller presentModalViewController:imagepicker animated:YES];
	
    return YES;
	
}
imagepicker is deallocated in the dealloc function of my parent view controller.

Now, after a person takes a photo I do the following:

Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
	
	//we need to save each image and then show it in the interface!
	int row = (self.numPhotos / 4);
	int mod = self.numPhotos % 4;
	
	UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
    [imageview setFrame:CGRectMake(mod * 80.0, row*120.0 + 120.0, 80.0, 120.0)];
	[self.view addSubview:imageview];
	
	[imageview release];
	
	self.numPhotos = self.numPhotos + 1;
	[self.navigationController dismissModalViewControllerAnimated:YES];

}
From running instruments I see that after I take the image, 8MB or so of space is taken up. But that space never gets released. So each time I take a photo, the memory goes up to hit 40MB which then causes the crash.

What am I doing wrong here? How do I clear the data taken by the UIImagePickerController class so that I'm not causing a crash after 5 pictures?

Cheers
I must be missing something.

For every photo (1600x1200 at RGBA, so 8MB), you create a UIImageView which displays the image, of course the memory usage increases by 8MB. About 4 of those full size images will make iPhone run out of memory and crash.

The problem (at least in the above code) is not the image picker, it is your code.
johnqh is offline   Reply With Quote
 

» Advertisements
» Online Users: 306
16 members and 290 guests
ADY, BdR, BrianSlick, dacapo, Joseph Nardone, laurielaptop, ligerligerliger, M@realobjects, mizzytheboy, oztemel, poisenden, Sunny46, syver, TheWebWizz, VikMyr, XRumerTest
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,876
Threads: 89,225
Posts: 380,701
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jorge599
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:39 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.