I have an aspx page that makes an Ajax request (using jquery) to a web service to return some data.
my onerror handler is something like this (not exactly but this is the idea):
onerror: function(status,xhr, whatever) {
var objectResult = eval('('+xhr.Status+')');
alert(objectResult.Message);
}
Question:
Will this create a potential memory leak due to the eval expression being assigned to my local var?
Thank you.
This will definitely not result in a memory leak.
Your
objectResultvariable will be destroyed at the end of the function (since it’s a local variable).The actual object in memory that
objectResultwas referencing is then free to be garbage collected (since the only variable referencing it was destroyed). It probably won’t be garbage collected right away, though.