d3由于匿名功能导致内存泄漏

时间:2018-10-05 06:18:36

标签: node.js d3.js socket.io

我正在运行一个websock,并在d3拨号组件中显示数据。 随着时间的推移,此窗口打开,所有组件都运转良好,并且可以平稳运行数小时。但是我有一个拨号组件,它将导致速度变慢。当删除匿名函数的返回值时,一切都很好。由于某种原因,返回匿名函数会导致越来越多的时间延迟。请注意--- 返回功能(步骤){

.attrTween("transform", function () {
            var pointerValue = value;
            if (value > self.config.max) pointerValue = self.config.max + 0.02 * self.config.range;
            else if (value < self.config.min) pointerValue = self.config.min - 0.02 * self.config.range;
            var targetRotation = (self.valueToDegrees(pointerValue) - 90);
            var currentRotation = self._currentRotation || targetRotation;
            self._currentRotation = targetRotation;

            return function (step) {
                var rotation = currentRotation + (targetRotation - currentRotation) * step;
                return "translate(" + self.config.cx + ", " + self.config.cy + ") rotate(" + rotation + ")";
            }
        });

0 个答案:

没有答案