iPhone crash randomly when calling a camera?
I have tested my app using instrument and it show the following leak.
![enter image description here][1]


when i double click on the CameraVC in the stack trace it refer to the following line into my code.
![enter image description here][2]  


  [1]: http://i.stack.imgur.com/SlffV.png
  [2]: http://i.stack.imgur.com/Togv4.png
this happen when I call the camera, I call it using the following code:-


          - (IBAction) getCamera
    {
    	// set up our camera overlay view	
    	// tool bar - handy if you want to be able to exit from the image picker...
    	UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-44, 320, 44)];
    	
    	UIBarButtonItem *spaceItem  = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace  target:nil action:nil] autorelease];
    	UIBarButtonItem *spaceItem1  = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace  target:nil action:nil] autorelease];
    	UIBarButtonItem *cancelItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel  target:self action:@selector(cancelPickingImag)] autorelease];
    	UIBarButtonItem *cameraItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera  target:self action:@selector(finishedAugmentedReality)] autorelease]; 
    	
    	spaceItem.width  = 2.0;
    	spaceItem1.width = 55.0;
    	NSArray *items=[NSArray arrayWithObjects:spaceItem,cancelItem,spaceItem1,cameraItem,nil];
    	[toolBar setItems:items];
    	
    	// create the overlay view
    	overlayView=[[OverlayView alloc] initWithFrame:CGRectMake(0, 300, 320, 480-44)];
    		
    	// important - it needs to be transparent so the camera preview shows through!
    	overlayView.opaque=NO;
    	overlayView.backgroundColor=[UIColor clearColor];
    	
    	// parent view for our overlay
    	UIView *parentView=[[UIView alloc] initWithFrame:CGRectMake(0,0,320, 480)];
    	[parentView addSubview:overlayView];
    	[parentView addSubview:toolBar];
    	[parentView addSubview:lbl];
    	[parentView addSubview:overlayGraphicView];
    	
    	// configure the image picker with our overlay view
    	//UIImagePickerController *picker=[[UIImagePickerController alloc] init];
    	
    	if ([UIImagePickerController isSourceTypeAvailable:
    		 UIImagePickerControllerSourceTypeCamera])
        {
    		imagePicker = [[UIImagePickerController alloc] init];
    		imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    		
    		// hide the camera controls
    		imagePicker.showsCameraControls=NO;
    		
    		imagePicker.delegate = self;
    		//imagePicker.allowsImageEditing = NO;
    	
    		// and put our overlay view in
    	    imagePicker.cameraOverlayView=parentView;
    	}
    	else
    	{
    		imagePicker = [[UIImagePickerController alloc] init];
    		imagePicker.delegate = self;
    		imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    		imagePicker.mediaTypes = [NSArray arrayWithObjects:
    								  (NSString *) kUTTypeImage,
    								  nil];
    		imagePicker.allowsEditing = NO;
    		
    	}
    
    	[self presentModalViewController:imagePicker animated:YES];
    	
    	//Free memory 
        [imagePicker release];//,imagePicker =nil;
    	[parentView release], parentView=nil;
    	[overlayGraphicView release], overlayGraphicView= nil;
    	[lbl release], lbl=nil;
    	[overlayView release];//, overlayView =nil;
    	[toolBar release], toolBar=nil;
    }



any help is highly appreciated 

Thanks

iPhone crash randomly when calling a camera?
===

I have tested my app using instrument and it show the following leak.
![enter image description here][1]


when i double click on the CameraVC in the stack trace it refer to the following line into my code.
![enter image description here][2]  


  [1]: http://i.stack.imgur.com/SlffV.png
  [2]: http://i.stack.imgur.com/Togv4.png
this happen when I call the camera, I call it using the following code:-


          - (IBAction) getCamera
    {
    	// set up our camera overlay view	
    	// tool bar - handy if you want to be able to exit from the image picker...
    	UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-44, 320, 44)];
    	
    	UIBarButtonItem *spaceItem  = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace  target:nil action:nil] autorelease];
    	UIBarButtonItem *spaceItem1  = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace  target:nil action:nil] autorelease];
    	UIBarButtonItem *cancelItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel  target:self action:@selector(cancelPickingImag)] autorelease];
    	UIBarButtonItem *cameraItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera  target:self action:@selector(finishedAugmentedReality)] autorelease]; 
    	
    	spaceItem.width  = 2.0;
    	spaceItem1.width = 55.0;
    	NSArray *items=[NSArray arrayWithObjects:spaceItem,cancelItem,spaceItem1,cameraItem,nil];
    	[toolBar setItems:items];
    	
    	// create the overlay view
    	overlayView=[[OverlayView alloc] initWithFrame:CGRectMake(0, 300, 320, 480-44)];
    		
    	// important - it needs to be transparent so the camera preview shows through!
    	overlayView.opaque=NO;
    	overlayView.backgroundColor=[UIColor clearColor];
    	
    	// parent view for our overlay
    	UIView *parentView=[[UIView alloc] initWithFrame:CGRectMake(0,0,320, 480)];
    	[parentView addSubview:overlayView];
    	[parentView addSubview:toolBar];
    	[parentView addSubview:lbl];
    	[parentView addSubview:overlayGraphicView];
    	
    	// configure the image picker with our overlay view
    	//UIImagePickerController *picker=[[UIImagePickerController alloc] init];
    	
    	if ([UIImagePickerController isSourceTypeAvailable:
    		 UIImagePickerControllerSourceTypeCamera])
        {
    		imagePicker = [[UIImagePickerController alloc] init];
    		imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    		
    		// hide the camera controls
    		imagePicker.showsCameraControls=NO;
    		
    		imagePicker.delegate = self;
    		//imagePicker.allowsImageEditing = NO;
    	
    		// and put our overlay view in
    	    imagePicker.cameraOverlayView=parentView;
    	}
    	else
    	{
    		imagePicker = [[UIImagePickerController alloc] init];
    		imagePicker.delegate = self;
    		imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    		imagePicker.mediaTypes = [NSArray arrayWithObjects:
    								  (NSString *) kUTTypeImage,
    								  nil];
    		imagePicker.allowsEditing = NO;
    		
    	}
    
    	[self presentModalViewController:imagePicker animated:YES];
    	
    	//Free memory 
        [imagePicker release];//,imagePicker =nil;
    	[parentView release], parentView=nil;
    	[overlayGraphicView release], overlayGraphicView= nil;
    	[lbl release], lbl=nil;
    	[overlayView release];//, overlayView =nil;
    	[toolBar release], toolBar=nil;
    }



any help is highly appreciated 

Thanks
