前不久一个swift项目用uicollectionview 用sdwebimage 加载图片,发生内存猛增,直接闪退的情况,简单说一下解决方案。

1、首先在appdelegate方法 didFinishLaunchingWithOptions

SDImageCache.sharedImageCache().maxCacheSize=1024*1024*8设置一下最大的缓存大小。

2、在appdelegate applicationDidReceiveMemoryWarning里加入

SDImageCache.sharedImageCache().clearMemory()

SDWebImageManager.sharedManager().cancelAll()

3、如果前面两种方法还是会发生内存泄露的话。

强烈推荐使用:gmgridview这个三方库,做好了内存处理和回收,效果和uicollectionview差不多。我原来用uicollectionview内存一下升到150M,但是用了gmgridview之后,最多36M。

上一篇:nginx tomcat 自动部署python脚本【转】


下一篇:crontab中运行python程序出错,提示ImportError: No module named解决全过程