Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS7 UIWebView Memory leak

We have an comprehensive iOS app with Hybrid mode - a UIWebView hold the major part of the web application in JS. It works fine on iOS6, but recently we found serious out of memory crash on all iOS7 device - iPad, iPhone 4/4S and iPhone 5/5C/5S. We did analysis of the memory consumption both on iOS6 and 7 in the iOS simulator. By doing same interaction in the app, the memory consumption of the WebView is always less than 200MB in iOS6, while it can exceed 800MB on iOS7!

We guess there is some serious memory management issue in the WebView on iOS7. But lack of the tool to profile the JS within the WebView, we cannot located the root cause. Here we'd like to ask whether anyone has similar problems, and any tool / approach can help further look insight the UIWebView to dig to the exact problem. THx.

like image 611
macapapa Avatar asked Nov 02 '13 04:11

macapapa


1 Answers

I don't have enough reputation to upvote or comment. So I think an "answer" is the only way that I can contribute.

I agree with Ming Zhu's contribution. I found that if you have 5 digit keys (9999 < key <= 99999) the memory usage on iOS 7 explodes.

Below is the example code that I came to when trying to reproduce what was crashing my app.

tempobj = {};

for(var i=1; i<2000; i++){
    var temp = {};
    tempobj[i] = temp;
    temp[98304] = "hello world";
}

I did also submit a bug to apple before finding this stackoverflow, but looks like that is a good thing anyways.

like image 136
dailynerd Avatar answered Sep 20 '22 07:09

dailynerd