I wonder whether memory leak can occur in the following pseudo jQuery code (because the success callback always have a reference to _this)?
var _this = this;
$.ajax({
url: "foo",
type: "POST",
data: data,
success: function() {
// Do stuff with _this
_this.doStuffs();
})
Is this code within a function ?
If yes (which I guess), _this will be illegible to garbage-collection right after the ajax call has completed or failed. So there is no reason in theory to worry about memory leak here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With