I am having the following observable arrays
in my view model:
VM.ListingData([]);
VM.ResumeListingData([]);
ListingData
will hold 20 columns x 100 rows of parsed JSON object. I am binding a grid using ResumeListingData
in the following way in the AJAX success method:
// To initially bind 10 records
R1ViewModel.ResumeListingData([]);
R1ViewModel.ListingData([]);
R1ViewModel.ListingData(JSON.parse(data.ResumeListing));//data.ResumeListing contains the JSON string returned from server through the ajax request
$.each(R1ViewModel.listingData(), function (index, item) {
if (index < 10) {
R1ViewModel.ResumeListingData.push(item);
return true;
}
return false;
});
Then I am calling the following bindNextItems
function at the end of AJAX success:
// To bind rest of the items
bindNextItems: function () {
VM.SetIntervalRef(setInterval(function () {
VM.ResumeListingData.push(VM.ListingData()[VM.SetIntervalCount()]);
VM.SetIntervalCount(VM.SetIntervalCount() + 1);
if ($('#rightTable tr').length == VM.listingData().length) {
clearInterval(VM.SetIntervalRef());
}
}, 1));
}
Now when I load the page for the first time and when I check browser memory usage in windows task manager it is around 250MB(tested in firefox). As I do some actions like searching, paging, filter, sorting etc on each of these actions 100 rows are returned from server, the memory usage of browser grows steadily and during my testing it reached up to 950MB of memory usage. I am not using any computed
observables or using a manual subscription
with both ResumeListingData
and ListingData
observable arrays. Just clearing them both using []
and assigning values in the above mentioned way when any action is performed.
Where can be the issue? I have faced this problem for the first time so are there any tools to monitor browser memory?
I am using setInterval
to bind 100 rows with a delay so that the browser doesn't hang when binding the table
. Is there any alternate better way to do this? Any other performance optimized way to push
items into an observable array
?