iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
niselover
V2EX  ›  iDev

使用 PhotoKit 框架加载图片 内存过高的问题

  •  
  •   niselover · Oct 8, 2016 · 3983 views
    This topic created in 3552 days ago, the information mentioned may be changed or developed.
    使用 PHImageManager requestImageForAsset: targetSize: contentMode: options: resultHandler:这个方法加载本地图片 动不动内存就飙到 200M+ dealloc 之后还是 100M+

    xcode 8.0 iPhone 6s 测试

    查了半天没有特别好的优化方案 有朋友遇到过这方面的问题吗 给点建议 多谢啦
    3 replies    2016-10-08 22:48:21 +08:00
    chipmuck
        1
    chipmuck  
       Oct 8, 2016
    看来都是被系统文档坑过的同道中人。。
    当时我死活找不到问题在哪里,在 stackoverflow 也很难找到问题答案,内存泄漏的问题比较难找。
    最后还是发现了解决方案,就是拿
    - requestImageDataForAsset:options:resultHandler: 这个方法来替代。具体的原因嘛,无非就是请求的一个是 UIImage 对象,一个是 NSData ,可能后者数据量比较小。
    我当时提的问题以及解决方案: http://stackoverflow.com/questions/39542540/memory-leak-when-using-placeholderforcreatedasset-property-in-phassetchangereque

    随手附上我个人博客上整理的将 asset-library 换成 photokit 的痛苦过程。。。
    http://chipmuck.pub/2016/09/22/photokithint/
    niselover
        2
    niselover  
    OP
       Oct 8, 2016
    @chipmuck 感谢 我学习一下哈
    LINAICAI
        3
    LINAICAI  
       Oct 8, 2016
    关键是事后能否及时释放吧。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5565 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 06:43 · PVG 14:43 · LAX 23:43 · JFK 02:43
    ♥ Do have faith in what you're doing.