So I'm in the early stage of writing the core engine of my new game. I'm planning on handling all the game's text (story, NPC, item description, etc.) from outside the editor, in order to allow easier editing and easier translation, and the ability to toggle between languages during gameplay. However, I'm concerned about memory usage, especially if I deploy on mobile.
I intend to make most of the game text into multiple json files, and reading only the json file(s) containing the necessary text on the screen. I'm not sure how javascript's memory control works though, thus this thread. So here's the default code for loading json files into data:
My question is as follow: does the
I intend to make most of the game text into multiple json files, and reading only the json file(s) containing the necessary text on the screen. I'm not sure how javascript's memory control works though, thus this thread. So here's the default code for loading json files into data:
Code:
DataManager.loadDataFile = function(name, src) {
var xhr = new XMLHttpRequest();
var url = 'data/' + src;
xhr.open('GET', url);
xhr.overrideMimeType('application/json');
xhr.onload = function() {
if (xhr.status < 400) {
window[name] = JSON.parse(xhr.responseText);
DataManager.onLoad(window[name]);
}
};
xhr.onerror = this._mapLoader || function() {
DataManager._errorUrl = DataManager._errorUrl || url;
};
window[name] = null;
xhr.send();
};
My question is as follow: does the
window[name] = null; actually remove the data from the json file from memory? Or does it still stay in the memory?


