I have a feeling I am implementing this wrong and because of that I am consuming larger amounts of memory each call to this method... I call this every 5 seconds and overtime the memory utilization goes up and up and up. Can someone review this and point out how I've implemented this wrong? I'm a relative newbie to javascript so don't be too hard on me
Code:get : function() { if (cip.simulation_mode == 'random') { cip.randomnumber2 = Math.floor(Math.random()* 0999999999999999); cip.url = '_xml/cipfe/simulation.php?rand=' + cip.randomnumber2; $('simgrouping').update('Randomized'); } else if (cip.simulation_mode == 'grouped') { cip.randomnumber2 = Math.floor(Math.random()* 0999999999999999); cip.grouping = general.random(0,11); cip.url = '_xml/cipfe/simulation.php?rand=' + cip.randomnumber2 + '&group=' + grouping; $('simgrouping').update('Grouped - ' + grouping); } if (cip.skip_next_pull == 'false') { new Ajax.Request(cip.url,{method: 'post', asynchronous: true, evalScripts: false, onCreate: function(u) { cip.xmitstart = new Date().getTime();}, onComplete: cip.process, onSuccess: function(u) { document['communication'].src = '_images_icons/' + layout.icon_path + '/monitor_xmit_anim.gif'; var xmittime = new Date().getTime() - cip.xmitstart - cip.xmitoffset; $('lastcipxmlxfer').update(cip.xmittime + 'ms.'); if (xmittime > cip.interval) { var overrun = cip.xmittime - cip.interval windowz.create('popup','yes','Race Condition','Race condition with an overrun of <font color="red">' + (overrun/1000) + ' seconds</font>. Network latencey or server load may be the cause. CIPfe automatically changed the update interval from ' + (cip.interval/1000) + ' second(s) to ' + ((cip.interval + 1000)/1000) + ' second(s).'); cip.change(cip.interval + 1000); // send error to server network error table for tracking. } // grouping (I removed this, not sure why it was sitting there. debugstring = '<font color="magenta">grouping</font>: ' + cip.grouping + ' <font color="magenta">interval</font>: ' + cip.interval; debug.write('<b>cip</b>.<font color="blue">get( )</font>',cip.xmittime,debugstring); }, onFailure: function(u) { document['communication'].src = '_images_icons/' + layout.icon_path + '/monitor_fail.png'; }, on404: function(u) { document['communication'].src = '_images_icons/' + layout.icon_path + '/monitor_fail.png'; } }); } cip.skip_next_pull = 'false'; // set skip pull back to false. },



Reply With Quote

Bookmarks