我正在开发一个应用程序UICollectionView
在一个ViewController
。UICollectionView滚动时收到内存警告
This CollectionView
这是一个画廊,每行3个图像。
我从服务器获取图像中的30张图片,第一网页地址和代码组,当细胞将被显示在cellForItemAtIndexPath
我用SDWebImage Library
异步下载那些图片。每30张图片我再次调用Web服务,并且我获得30张图片,并发送带有限制和偏移量的请求。这可能发生100次,有3000张图片的配置文件。
好吧,我的问题来了一个我启动应用程序在我的iPhone 4,一些快速滚动后,我开始得到Received Memory Warnings
和一些警告后,应用程序崩溃。当我在模拟器中进行相同的测试时,没有什么不好的事情发生。
每次我下载30幅图象I添加结果数组到它处理CollectionView
数据和reload
的collectionView
的NSMutableArray *data property
。我试图用分配的仪器,但是我很难理解正在发生的事情。
这是我用来创建细胞
-(UICollectionViewCell *)collectionView:(LZProfileImagesCollectionView *)aCollectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if(aCollectionView == self.imagesCollectionView){
if([self.data count] - 12 == indexPath.row){
self.photoOffset += 30;
[self loadUserData];
}
LZProfileCollectionViewCell * cell = (LZProfileCollectionViewCell *)[imagesCollectionView dequeueReusableCellWithReuseIdentifier:ImageCollectionCellIdentifier forIndexPath:indexPath];
Image *image =(self.data)[indexPath.row];
[cell configureCellWithImage:image];
return cell;
}
return nil;
}
的代码和LZProfileCollectionViewCell
细胞我有这样的一个:
-(void)configureCellWithImage:(Image *)image
{
[self setNeedsDisplay];
// Imagen
NSString *imageUrl = [kBaseURL stringByAppendingString:image.imageStringUrl];
[self.pictureImg setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:kDefaultLoadingImage]];
[self.pictureImg setContentMode:UIViewContentModeScaleAspectFit];
}
我采取setImageWithURL
从SDWebImage
3后几分钟我在仪器中获得此快照(统计)
预先感谢您
如果您正在使用第三方库,则由您来确保您已将其配置为进行适当的缓存。当您需要释放内存时,您还负责清除缓存。 Allocations工具对于使用内存的位置有何评论? –
我对通常的请求使用了'AFNetworking',对图像异步下载使用了'SDWebImage'。在乐器配置中你想看到什么?调用树,分配列表? – croigsalvador
从'Statistics'->'Object Summary'开始并查看顶部的'Live Bytes'对象。或张贴屏幕截图。以及一些堆镜头。 –