Does this leak in IE?
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.M开发者_运维知识库essage);
}
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 objectResult
variable will be destroyed at the end of the function (since it's a local variable).
The actual object in memory that objectResult
was 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.
No, this should not create a memory leak. The objectResult
variable should be cleaned up as it leaves scope when your handler finishes.
精彩评论