JQuery XHR Memory Leak Workaro...

Matlab Waveform Deconvolution

3D Printer Unboxing: Wanhao Du...

Flashing Nordic NRF51 With J-L...

Electric Standing Desk

Hardware Controlled LED Lamp

Ultrasonic Digital Signals Pro...

Bluetooth Low Energy Garage Op...

Mini Cast-Iron Deep Dish Pizza

Homebrewed Columbus IPA

Mini Gingerbread Houses

Iced Brownies
JQuery XHR Memory Leak Workaround
JQuery's implementation of the XMLHttpRequest (XHR) object inside of the jQuery.ajax() function appears to leak memory, through the browser keeping an internal reference to the XHR. This subsequentially manifests itself inside of the jQuery getJSON() and post() functions. These functions have to be repeatedly used thousands of times before any significant amount of leaked memory begins to add up.

To fix this, in some circumstances, we can rewrite the functions to recycle the same XHR object (or a set of XHR objects).

To replace jQuery.post(url, jsonData), we can do something similar to the following (I only needed one XHR instance in my case):

var xhrPostTable = [];

xhrPostTable[0] = new XMLHttpRequest();

function jqueryPostReplacement(postURL, postJSON){
   xhrPostTable[0].open("post", postURL, true);
   xhrPostTable[0].setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   xhrPostTable[0].send( $.param(postJSON, true) );

To replace jQuery.getJSON(url, callbackFunction), we can do something similar to the following (Again, I only needed one XHR instance in my case):

var xhrGetTable = [];

xhrGetTable[0] = new XMLHttpRequest();

function jqueryGetReplacement(getURL){
  xhrGetTable[0].open("get", getURL, true);

xhrGetTable[0].onload = function() {
	//Callback functionality