jquery - freeing memory after ajax request -
after ajax requst can free memory doing this?
function ajax(){ this.url = null; this.data = null; this.success = null; this.global = true; this.timeout = json_timeout; this.cache = false; this.datatype = 'json'; this.type = 'post'; var _this = this; this.send = function(){ var jqxhr = $.ajax({ url : this.url, data : this.data, timeout : this.timeout, cache : this.cache, datatype : this.datatype, type : this.type, global : this.global } ) .success(this.success) .error(function(){ dialog.set_error({ headline : lang.get('hdl_error'), body : lang.get('err_timeout'), btns : [ { value : lang.get('btn_ok'), script : function(){}, focus : true } ] }) }) .complete(function(){ delete _this; }); }; }
no. delete
doesn't release memory, removes properties objects. if call on var
(as you've done), has no effect.
javascript garbage-collected language. memory consumed object automatically reclaimed when nothing has reference object anymore. circular references handled automatically (so if a
refers b
, b
refers a
, provided nothing else refers a
or b
, can both reclaimed).
where run issues circular references non-javascript objects, on browsers (i'm looking @ you, microsoft). if have dom element refers object (say, function), , object refers dom element, on ie if nothing else refers either of objects, they'll never reclaimed. wouldn't seem case example.
(re statement delete
above: if happens property you're removing object refers object nothing else refers to, removing property makes object available reclaimed. that's side effect, , again, delete
relates properties, not variables.)
Comments
Post a Comment