I am loading entire data of .html files in a div via ajax call. The html page contains link,script tags required for HTC(html component) to bind with the elements on page.
The structure of the page is like:
I am using jQuery to load HTML pages like this
<body>
<input type="radio" class="openpage" id="0001">
<input type="radio" class="openpage" id="0002">
<input type="radio" class="openpage" id="0003">
<input type="radio" class="openpage" id="0004">
<div id="loadPage"></div>
<script>
$(document).ready(function(){
$(".openpage").on("click",function(){
$("#loadPage").load($(this).attr("id")+".html",function(){
//load a page with many htc bindings and external references
//trigger some onload functions which are not called automatically in IE
//confirmed this is in chrome
});
});
})
</script>
</body>
The problem with this is that IE memory keeps pilling up as radio buttons are clicked to load pages and after loading few pages browsers stops responding. I can see the memory going up in task manager.
The application runs in IE 5,6,7,8,9 and in quirks mode in IE10. I tried to replicate the same scenario in chrome and it showed no problem. So I think it is IE specific memory management related problem.
I read many articles but I was not convinced.I also read this question on SO but it suggests to load only some part of page which is not acceptable in my case.This article seems relevant but I am not sure what exactly causes memory leak in my case.
The entire body above is actually in a iframe . So as a workaround I reload the frame with the main page containing after 8 clicks of radio button. I have tried to clear stuffs before each load using:
$("#loadPages").empty();
$("#loadPages").find("*").off();
$.ajaxSetup({ cache: false });
But nothing works.So I doubt whether jquery can clear events registered through htc.
1) It would be great if you explain the reason of memory leak in this case.
2) And in general why memory leak can occur in a browser after loading many resources. This does not happen in modern browsers but why it occurred in older browsers.
3) Is there a way to release browsers memory without refreshing the frame.
4)Is there a way to check what all resources are residing in a browsers memory.