简体   繁体   English

使用raover的raphael.js内存泄漏

[英]Memory leak using raphael.js with hover

There is a serious memory leak happening using the Raphael library pie chart WITH the hover attribute. 使用带有hover属性的Raphael库饼图发生严重的内存泄漏。 If I remove the code that includes the hover attribute it works great and when I add it back in the memory footprint steadily grows and hovering over the piechart increases the memory footprint even more so. 如果我删除包含hover属性的代码,它可以很好地工作,当我将其添加回内存占用时,它会稳步增长并且悬停在饼图上会增加内存占用量。 Unlike most other examples I'm using window.setInterval to constantly update the page (if this helps any). 与大多数其他示例不同,我使用window.setInterval来不断更新页面(如果这有帮助的话)。 I'm at a loss as to how to correct this issue and reaching out for some help. 我不知道如何纠正这个问题并寻求一些帮助。

Below is the basics of what I'm doing...using pretty much the dynamic pieChart on the Raphael website and adding an interval timer to it. 下面是我正在做的基础知识......在Raphael网站上使用了几乎动态的pieChart并为其添加了间隔计时器。 I cant however figure out how to utilize the hover effect without the memory issue???: 但我无法弄清楚如何在没有内存问题的情况下利用悬停效果???:

 window.onload = setInterval(drawThePie, 10000);
function drawThePie() {
    var mainCont = parent.frames["main"].document;
    mainCont.getElementById("holder").innerHTML = "Getting data..";

    //..Setting values for pieChart and legend into arrays here

    //..Looping through color array and setting values for colorlist below

            var r = Raphael("holder");
    var aCircle = r.aCircle(85,85,78).attr({fill: "black"});

            pie = r.piechart(85,85,75,data, {"legend": legend, "legendpos": "east", colors: colorlist });
    if(dataNotZero > 0) { mainCont.getElementById("holder").innerHTML = "";}

            pie.hover(function () {
                this.sector.stop();
                this.sector.scale(1.1, 1.1, this.cx, this.cy);

                if (this.label) {
                    this.label[0].stop();
                    this.label[0].attr({ r: 7.5 });
                    this.label[1].attr({ "font-weight": 800 });
                }
            }, function () {
                this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");

                if (this.label) {
                    this.label[0].animate({ r: 5 }, 500, "bounce");
                    this.label[1].attr({ "font-weight": 400 });
                }
            });
        };

It can not see your all code. 它无法看到您的所有代码。 so i just can guess... 所以我只能猜到......

maybe this part was worng 也许这部分是故事

this.sector.scale  

this part of code maybe got some value which hava some DOM Reference. 这部分代码可能有一些值得一些DOM参考。 when the function was got end,the value still not release the DOM Reference. 当函数结束时,该值仍未释放DOM Reference。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM