2014-12-30 2 views
0

서버에서 비동기 다운로드 이미지로 SDWebImage을 사용하고 있습니다. 나는 iOS 8.1와 아이폰 5와 5s에서 애플 리케이션을 테스트하고 괜찮아요 메모리 경고 all.But (아이폰 4s를 사용하여) 클라이언트에게 빌드 주어진 및 이미지를로드하는 동안 그는 불행히도 나는 아이폰 4s 그래서 문제를 알아낼 수 없습니다. 필자는 iPhone5가 장착 된 도구로 테스트를 실시했으며, 여러 번 실행 한 후 스크린 샷을 찍었습니다. screen shot using iPhone 5 그리고 여기 내가 didRecdeiveMemoryWarnig 방법이미지를 다운로드하는 중 iPhone4s에서 앱이 다운 됨

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
    NSLog(@"memory warning received in voucher"); 
    [[SDImageCache sharedImageCache] clearMemory]; 
    [[SDImageCache sharedImageCache] cleanDisk]; 
    [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"]; 
} 

메모리를 지워 않았다

-(void)setImageWithUrl:(NSURL*)imgurl onImageView:(UIImageView*)image prograssive:(BOOL)progressive 
{ 

    __block UIActivityIndicatorView *activityIndicator; 

    __weak UIImageView *weakImageView = image; 

    SDWebImageOptions opt; 
    if (progressive) { 

     opt = SDWebImageProgressiveDownload; 
    } 
    else 
     opt = SDWebImageRetryFailed; 

    [image sd_setImageWithURL:imgurl placeholderImage:[UIImage imageNamed:@"default_image"] options:opt progress:^(NSInteger receivedSize, NSInteger expectedSize) 
    { 
     if (!activityIndicator) 
     { 
      [weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]]; 
      activityIndicator.center = CGPointMake(weakImageView.frame.size.width /2, weakImageView.frame.size.height/2); 
      // activityIndicator.center = weakImageView.center; 
      [activityIndicator setBackgroundColor:[UIColor clearColor]]; 
      [activityIndicator startAnimating]; 

     } 
    } 
        completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) 
    { 

     [activityIndicator removeFromSuperview]; 
     activityIndicator = nil; 
    }]; 
} 

이미지 다운로드에 대한 내 코드입니다하지만 여전히 어떤 일이 무슨 날 GUID를 아이폰 4s.Can에 충돌?

+1

테스트 응용 프로그램에 Crashlytics를 추가하고 충돌 보고서를 수집 한 다음 충돌을 분석하면 가장 안정적인 솔루션이됩니다. –

+0

로그인을 시도하고 있지만 "목록에 있습니다"라고 표시되어 있지만 Crashlytics 계정이없고 생성하려고 시도했지만 초대장을받지 못했습니다. – Blios

+0

이 경우 메모리 문제를 정렬하는 데 도움이 될 수 있습니다. http://stackoverflow.com/questions/26921227/table-view-images-never-being-released/26925176#26925176 – Kampai

답변

0

메모리 압박으로 인해 앱이 죽는 것처럼 들립니다. 어쩌면 어떤 메모리 스파이크를 완화하기 위해 Autorelease Pool을 사용해보십시오. didReceiveMemoryWarning에서 수행중인 작업이 실제로 이러한 상황에서 도움이되지 않는다고 생각하기 때문일 수 있습니다.