开发者

Does this leak in IE?

开发者 https://www.devze.com 2023-03-23 14:42 出处:网络
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):

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号