I am using XMLHttpRequest to download the file of size 750mb as arraybuffer. The problem is that after downloading the file, the memory is not released to the os even after deleting the XMLHttpRequest object. My sample code is
<!DOCTYPE html>
<html>
<body>
<div id="demo">
<button type="button" onclick="loadXMLDoc()">load the file</button>
<button type="button" onclick="clear()">clear</button>
</div>
<script>
var xhttp = null;
function loadXMLDoc() {
if(xhttp == null)
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(xhttp.response);
delete xhttp;
xhttp = null;
}
};
xhttp.open("GET", "http://192.168.1.104/gltf/bmw/buffer.bin", true); //buffer.bin is 750 mb
xhttp.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhttp.responseType = 'arraybuffer';
xhttp.send();
}
function clear()
{
delete xhttp;
xhttp = null;
}
</script>
</body>
</html>
1) is this the right way to delete the XMLHttpRequest object?
2) How to make the XMLHttpRequest to release the memory back to the os?
Thanks