iOS7 webkit经常崩溃 - 不释放内存? [英] iOS7 webkit crashes frequently - not freeing up memory?

查看:269
本文介绍了iOS7 webkit经常崩溃 - 不释放内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到我的Phonegap应用程序在iOS7上有一些内存问题,iOS6上没有发生。



  1. p>对于#1,这在iOS6上从不是一个问题,不管设备是什么。



    对于#2,我重新使用相同的DIV元素来显示下一个



    这篇文章中提到的技术在iOS7中似乎不再有效:
    在JavaScript中加载图片时iPad / iPhone浏览器崩溃

    解决方案

    找到的最好的解决方案是下面的代码:

      var img = document.getElementById('imageID'); 
    img.parentNode.removeChild(img);
    img.src ='data:image / gif; base64,'+
    'R0lGODlhAQABAAD / ACwAAAAAAQABAAACADs =';
    setTimeout(function(){
    img = null;
    },60000);

    这将src属性设置为一个微小的gif,然后等待足够长的时间,以便垃圾回收最终发生。



    请参阅: http://www.fngtps.com/2010/mobile-safari-image-resource-limit-workaround/



    这应该适用于您。我可以通过使用Xcode仪器来验证内存是否已释放。不幸的是,这个解决方案似乎不适用于我使用的主屏幕应用程序。


    I'm noticing my Phonegap app is having some memory issues on iOS7 that weren't happening on iOS6 .

    1. long iScroll lists with many images
    2. displaying images from the phone's album (9mp) will crash after you view several

    For #1, this was never an issue on iOS6, regardless of device.

    For #2, I am re-using the same DIV element to display the next picture, so it seems that the previous image is not being cleared.

    The techniques mentioned in this post no longer appear to work in iOS7: iPad/iPhone browser crashing when loading images in Javascript

    解决方案

    The best solution for this problem I found is the following code:

    var img = document.getElementById('imageID');
    img.parentNode.removeChild(img);
    img.src = 'data:image/gif;base64,' + 
          'R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
    setTimeout(function() {
    img = null;
    }, 60000);
    

    This sets the src attribute to a tiny gif and then waits long enough for garbage collection to happen eventually.

    See: http://www.fngtps.com/2010/mobile-safari-image-resource-limit-workaround/

    This should work for you. I could verify that the memory is released by using the Xcode instruments. Unfortunately this solution doesn't seem to work for homescreen apps which I am using.

    这篇关于iOS7 webkit经常崩溃 - 不释放内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆