Ajax Refresh Memory Issue

  

Hi,

I'm using the following piece of code to refresh the page through Ajax every 30 seconds. 

"<script language='javascript' type='text/javascript'>
<!--

var timer_"+ContainerTudo.Id+";
function fun_"+ContainerTudo.Id+"() {
    clearTimeout(timer_"+ContainerTudo.Id+");
    timer_"+ContainerTudo.Id+" = setTimeout(""fun_"+ContainerTudo.Id+"()"","+30000+");
    osjs('#"+HiddenButton.Id+"').click();
}

osjs(document).ready(function() {
    clearTimeout(timer_"+ContainerTudo.Id+");
    fun_"+ContainerTudo.Id+"();
});

// -->
</script>"

It's a simple web page serving as a panel that shows information on a big screen. It only contains a grid that never fetches more than 15 to 25 records at time.

It works fine but the browser eventually crashes when it runs out of memory. I left it running for a weekend and by monday morning Internet Explorer 11 was frozen and memory usage at 1,7GB. Chrome 54 also had a similar behavior, crashing the page, but it's memory usage was as low as 165MB.

When it crashes, I simply refresh the page and it starts working again, and the memory usage drops to less than 20MB. But after some hours the memory is at high levels again, triggering the same problem over and over.

Any ideas about how to solve this problem?

Thanks in advance.

Hi,



what does the click exactly do?

are you sure you are not refreshing the javascript as well?

hence increasing the amounts of clicks everytime?


Imho, I would make it simpler.

just 1 call to waut 30second, then click.

and call that javascript after the refresh.


so the function is this, much simpler

function callClick(btnId) { 
        setTimeout( function() { $('#'+ btnId).click(); }, 30000); 
}


and that function you run in your refresh-action.

this piece of code is inside the refersh-container

<script>callClick('"+ContainerTudo.Id+"');</script>


and you start of with 

$(document).ready(function() {
    callClick('"+ContainerTudo.Id+"');
});