search

Home  >  Q&A  >  body text

ios - 关于APP 内存偏高出现闪退问题的研究,求大神解答!!!

问题描述:app 出现内存偏高的问题,app 是一个展示图片居多的app,浏览多个图片list 页以后,内存最高峰值跑到了150m,然后app 出现了闪退;
问题:
① 怎么能够避免内存偏高的问题?
② 如果不能避免那么怎么降低内存偏高呢?
③ 如果上面两个问题都不能解决,那么出现内存偏高的时候怎么处理可以避免闪退呢?

伊谢尔伦伊谢尔伦2772 days ago720

reply all(7)I'll reply

  • 阿神

    阿神2017-04-18 09:20:33

    1. Please make sure to try the real device release mode for testing

    2. Please make sure the memory is not leaked

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:20:33

    As mentioned above, first check whether there is a memory leak.

    1. What is the cause of crash? If you don't see the log, you can't be sure that it is caused by high memory.
    2. If you browse the list of images, you can use SDWebImage or the like to cache the images, set the upper limit of the memory used by the cache, and reuse the table, which will not use a lot of memory.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:20:33

    If too many pictures are displayed and the memory increases, first check whether the pictures have been released. Under normal circumstances, the pictures are not released in time.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:20:33

    If the memory suddenly becomes high after a certain operation and remains stable or continues to rise, it can basically be determined to be a memory leak.
    When judging a memory leak, first, you should determine where the memory leak occurs in the code;
    Second, if it is caused by pictures, it may be because the network requested pictures do not have a local cache;
    Third, pay attention Network requests, database operations, release of UIView classes and subclasses.
    Finally, you can debug the project in XcodeProduct->Profile, wait for the compilation to be completed, call up Instruments, and use Leaks to check memory leaks.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:20:33

    A more common image optimization may also be that the images in the original data are too large, causing the memory to increase. It is recommended to use thumbnails in lists.

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:20:33

    Do some reasonable release operations to open up space when used.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:20:33

    I think the pictures on the cells that slide out of the screen are not released. Generally speaking, the cells that slide out of the screen will be released-->The content in the cell is released-->UIImageView is released-->Then UIImage Release, check whether there is a link in the release chain that has not been released. It is more likely that your UIImage object is referenced elsewhere, such as stored in NSArray, such as in NSCache. Release means saving this object without any strong references

    reply
    0
  • Cancelreply