samedi 27 décembre 2014

Make garbage collector happier in Browser


We have following code.



recorderProcess : function (e) {
var left = e.inputBuffer.getChannelData(0);
var samples = this.resampler.resampler(left);
var leftSix = convertFloat32ToInt16(samples);
var send = G711.encode(leftSix, {
alaw: this.encMode == "alaw" ? true : false
});
vApp.wb.utility.audioSend(send);
}


https://github.com/vidyamantra/virtualclass/blob/86a474e2c8e3eb3877fc12d947890984cbc7fb5c/src/media.js#L329


We are capturing audio (Raw PCM) from browser, encoding to to G711 and sending it over websocket. Problem with this code is that it is making browser Garbage Collector (GC) aggressive.


How can we make GC happier so that it has to do less work?


We tried making variables global but that is not helping us.


UPDATE 1


Ading Live code and Chrome Timeline Memory View.


http://jsfiddle.net/s05q4o3p/


Chrome showing GC in action





Aucun commentaire:

Enregistrer un commentaire