I have a PhoneGap / JQuery MObile application that receives data from a server through Ajax and displays it in a list. With each Ajax sample, the memory occupied by the application increases by about 10 MB. For the first sample, everything may be in order, since it selects a large number of records (about 700). However, for subsequent calls, I understand that it should reuse memory, and not accumulate another 10 MB each time. I used .off () to free event handlers if they held memory, but to no avail.
Here is the main Div page where the output is displayed:
<div data-role="content" class="MainContent" style="overflow:hidden; padding-top: 0px;"> <ul data-divider-theme="b" data-role="listview" data-inset="true" class="MainMenu"> </ul>
And this is JavaScript code that selects data from the server and displays it in the section above.
AjaxFile = "mydomai.com/ajax.php"; $.get(AjaxFile, function (AjaxData) { $( ".PL" ).off(); $(".MainMenu").off(); $(".MainContent").off(); AjaxData = '<li class="MainMenuList" data-role=list-divider>' + gTitle + AjaxData; $(".MainMenu").empty(); $(".MainMenu").html(AjaxData); $(".MainMenu").listview('refresh'); window.scrollTo(0, 0); $.mobile.loading('hide'); HighlightRow(gCurrentFile); $(document).ready(function () { $(".PL").click(function () { if ( !$(this).hasClass("BTitleRow") ) { $(".PL").removeClass("RowHighlight"); $(this).addClass("RowHighlight"); OpenNewLink($(this).attr('name')); } }); }); }); AjaxData = null; return;
How to free up memory and ensure reuse of the same memory instead of storing more and more memory?
Update
Even if I remove the bottom, I still see an increase in memory usage:
$(document).ready(function () { $(".PL").click(function () { if ( !$(this).hasClass("BTitleRow") ) { $(".PL").removeClass("RowHighlight"); $(this).addClass("RowHighlight"); OpenNewLink($(this).attr('name')); } }); });
It seems that some kind of memory leak has occurred in Ajax, as well as viewing the list ("refresh").
source share