2011-10-10 7 views
0

현재 진행중인 iOS 프로젝트에서 작업 중이지만 iOS의 전체 메모리 내용 이 제대로 작동하지 않습니다.Objective C, iOS - 메모리 수신 경고

아이폰 카메라는 스트림을 녹화합니다. 대기열을 통해 실행되는 캡처 방법이 있습니다. camer 이미지가 그레이 스케일로 변환됩니다. 그것은 잘 작동하지만 얼마 후 메모리 경고를 제공하고 메모리가 부족하기 때문에 응용 프로그램을 닫습니다.

난 이후 배수 오토 릴리즈 풀 내부

CGColorSpaceRef colorSpaceGray = CGColorSpaceCreateDeviceGray(); 
CGContextRef newContextGray = CGBitmapContextCreate(baseAddressGray, width, height, 8, width, colorSpaceGray, kCGImageAlphaNone); 

CGImageRef GrayImage = CGBitmapContextCreateImage(newContextGray); 


UIImage *img= [UIImage imageWithCGImage:GrayImage scale:1.0 orientation:UIImageOrientationRight]; 
[self.imageView performSelectorOnMainThread:@selector(setImage:) withObject:img waitUntilDone:NO]; 



free(baseAddressGray); 
CGColorSpaceRelease(colorSpaceGray); 
CGContextRelease(newContextGray); 


CVPixelBufferUnlockBaseAddress(imageBuffer,0); 

모든 거짓말을 여기까지 오류 소스를 발견했다.

CGColorSpaceRelease(colorSpaceGray); 
CGContextRelease(newContextGray); 

이 해제되기 때문에 충돌에 대한 소스 번째입니다 라인, 여기에는 메모리 문제가 없을 것 내 이해에서

CGContextRef newContextGray = CGBitmapContextCreate(baseAddressGray, width, height, 8, width, colorSpaceGray, kCGImageAlphaNone); 

입니다.

여기서 내가 잘못하고있는 것이 무엇이며 무엇이 누락 되었습니까?

답변

1

코드 샘플의 라인 4에 GrayImage을 릴리스하지 않았습니다.

+0

감사합니다. – chris