weixin_33712987 2010-01-28 15:51 采纳率: 0%
浏览 46

Ajax内存泄漏

I am experiencing a slow memory leak in both IE and Firefox using a combination of ASP.NET AJAX and jQuery. My scenario is very similar to the one described here : Preventing AJAX memory leaks except using jquery and asp.net AJAX, not protyotype: I have a webpage displaying data in an UpdatePanel that is refreshed every 60 seconds using a timer. in the AJAX javascript pageLoad function that is called on every "partial postback", I re-bind events because they are lost in the asp.net partial postback:

function pageLoad(sender, args) {
    $("#item").unbind();
    $("#item").hover(
        function() {
            // do something
        },
        function() {
            // do something
        });
}

so this is called every 60 seconds. Could this alone be the cause of a memory leak?

  • 写回答

2条回答 默认 最新

  • hurriedly% 2010-01-28 15:56
    关注

    Do this instead:

    $(function() { //.ready shortcut...
      $("#item").live("hover",
        function() {
            // do something
        },
        function() {
            // do something
        });
     });
    

    Note, this requires jQuery 1.4.1, but acts entirely different in terms of memory. It attaches to the entire DOM watching for the event to bubble instead of attaching a new event to every object your're inserting every 60 seconds.

    评论

报告相同问题?

悬赏问题

  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误