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 mem
Both the UIWebView and the native safari browser with iOS7 seems to have a problem in memory management when handling json object. If you have a dictionary with a deep nested structure, and you happen to have one of the key to be a numeric string, and it is less than 99999, you might have received memory warnings frequently.
something like,
{"**98304**":
{"key":
{"2ndLevelKey":
{
"address":"10928 Homestead rd","city":"Cupertino","Zip":95014
}
}
}
}
The work around is simple, try to replace the key "98304" something like "ID98304". Hope you have tackled the problem already. :)
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.