iOS7 webkit crashes frequently - not freeing up memory?

前端 未结 1 1749
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 14:03

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 im
相关标签:
1条回答
  • 2020-12-06 14:34

    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.

    0 讨论(0)
提交回复
热议问题