javascript - How to prevent and guard against closure memory leaks -


var utils = (function() {   var playlistutils = (function() { // playlist utils     return {       saveplaylisobj: function(playlist) {         if (playlist) {           localstorage.setitem('playlistobj', json.stringify(playlist));         }       },       getplaylistobj: function() {         var plobj = localstorage.getitem('playlistobj');         if (plobj) {           return json.parse(plobj) || {};         }       }     };   })();     return {     playlistutils: playlistutils   }; })(); 

could closure possibly causing memory leak ?

i'm running issue chrome mobile android crashes intermittently when running web application.

reference: what stack trace mean?

app specifics : server : jboss frameworks : angular heavy, javascript , jquery

i don't see leak here. and, regardless leak material has either hold large amount of memory or created , leaked thousands of times or combination of two. doesn't declared more once , not hold large amounts of memory.

in case, use of iifes here overcomplication (leading hard follow code) , entirely unnecessary. can instead use object literal has no opportunity closure:

var utils = {     playlistutils: {         saveplaylistobj: function(playlist) {             if (playlist) {               localstorage.setitem('playlistobj', json.stringify(playlist));             }         },         getplaylistobj: function() {             var plobj = localstorage.getitem('playlistobj');             if (plobj) {               return json.parse(plobj) || {};             }         }     } }; 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -