I'm building a mobile web app that will rely on caching. If my cache uses to much memory I'm seeing this message in mobile Safari...
"A problem occurred with this webpage so it was reloaded".
Without intervention the page will reload and do the same thing over again a few times until it gives up.
Are there events I can capture, heap information I can monitor or settings that I can change to build a caching system that is more resilient than forcing page reloads?
Chrome has window.performace.memory
but I can't seem to find anything related to solving my issue in mobile Safari. Try/catch statements and onBeforeUnload events don't prevent the page loads or provide an opportunity to clear/reduce the cache.
Open the Start menu, search for Advanced System Settings, and select the Best match. In the Variable name field enter NODE_OPTIONS. In the Variable value field enter --max-old-space-size=4096. This value will allocate 4GB of virtual memory to Node.
JavaScript code can experience memory leaks by keeping hidden references to objects. Hidden references can cause memory leaks in many unexpected ways.
This generally occurs on larger projects where the default amount of memory allocated by Node (1.5gb) is insufficient to complete the command successfully.
This exception can be solved by increasing the default memory allocated to our program to the required memory by using the following command. Parameters: SPACE_REQD: Pass the increased memory space (in Megabytes).
Does this help ?
Error handling "Out of Memory Exception" in browser?
var localStorageSpace = function(){
var allStrings = '';
for(var key in window.localStorage){
if(window.localStorage.hasOwnProperty(key)){
allStrings += window.localStorage[key];
}
}
return allStrings ? 3 + ((allStrings.length*16)/(8*1024)) + ' KB' : 'Empty (0 KB)';
};
var storageIsFull = function () {
var size = localStorageSpace(); // old size
// try to add data
var er;
try {
window.localStorage.setItem("test-size", "1");
} catch(er) {}
// check if data added
var isFull = (size === localStorageSpace());
window.localStorage.removeItem("test-size");
return isFull;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With