简体   繁体   English

使用平移关联两个图形时绘制内存泄漏

[英]Flot memory leak while associating two graphs using panning

we are rendering two graphs with flot, which share the same x-axis. 我们用flot渲染两个图,它们共享相同的x轴。 we plot them with: 我们绘制它们:

plot1 = $.plot($("#placeholderGraph1"), p1_data, d1_options);
plot2 = $.plot($("#placeholderGraph2"), p2_data, d2_options);

we need to make sure that panning and zooming on one graph also redraws the other and vice versa. 我们需要确保在一个图形上平移和缩放也会重绘另一个图形,反之亦然。 we achieve this with the following binding: 我们通过以下绑定实现此目的:

$("#placeholderGraph1").bind("plotpan", adjustGraph1Axes);
$("#placeholderGraph2").bind("plotpan", adjustGraph2Axes);

If we don't add these last two statements, there is no memory leak and browser(all the browsers) drops memory whenever it redraws. 如果我们不添加最后两个语句,则没有内存泄漏,浏览器(所有浏览器)在重绘时会丢失内存。 But with the above binding, browser never drops memory and it piles up towards hundreds of megabytes. 但是通过上面的绑定,浏览器永远不会丢失内存,它会累积到数百兆字节。

Apart from this, we also update individual legends with mouse movements. 除此之外,我们还通过鼠标移动更新单个图例。

we tried following approaches for the memory leak, but none worked: 我们尝试了以下内存泄漏的方法,但没有一个工作:
1. making plot1 and plot2 global variables and explicitly deleting the contents 1.制作plot1和plot2全局变量并明确删除内容
2. Deleting the graph divs and recreating 2.删除图形div并重新创建
3. Explicitly unbinding events before rebinding 3.重新绑定之前显式解除绑定事件
4. Plotting an empty graph before redrawing 4.在重绘之前绘制空图

Any other approaches to associating two graphs or dumping memory? 关联两个图表或转储内存的任何其他方法?

Issue might be with the Flot Plugin: jquery.flot.navigate.js. 问题可能在于Flot插件:jquery.flot.navigate.js。

I suggest you to upgrade to JQuery to Version-1.5 along with the flot plugin mentioned above. 我建议你升级到JQuery到版本1.5以及上面提到的flot插件。

You may like to visit this link (refer: ChangeLog towards your right side): 您可以访问此链接(请参阅:右侧的ChangeLog):

https://code.google.com/p/flot/source/browse/trunk/jquery.flot.navigate.js?r=317 https://code.google.com/p/flot/source/browse/trunk/jquery.flot.navigate.js?r=317

I may have had a similar issue synchronizing the selection on an overview plot and panning/zooming in the main plot; 我可能有一个类似的问题同步概览图上的选择和主图中的平移/缩放; my issue was that the event handler for one plot was triggering the event for the other plot and the execution of the corresponding event handler was triggering the event for the first plot, which caused the original event handler to execute...leading to an infinite loop. 我的问题是,一个绘图的事件处理程序触发了另一个绘图的事件,并且相应的事件处理程序的执行触发了第一个绘图的事件,这导致原始事件处理程序执行...导致无限环。

In other words, are you sure your issue isn't that the execution of adjustGraph1Axes isn't triggering the plotpan event for graph 2 which causes the execution of adjustGraph2Axes unintentionally, which trigger the plotpan for graph 1 and causes adjustGraph1Axes to execute and so on? 换句话说,你确定你的问题不是adjustGraph1Axes的执行没有触发图2的plotpan事件,这会导致无意中执行adjustGraph2Axes ,这会触发图1的plotpan并导致adjustGraph1Axes执行等等? My post along with the solution is located here: Flot event for range updates in response to panning/zooming . 我的帖子和解决方案位于此处: Flot事件用于范围更新以响应平移/缩放

I used a flag to solve the ping-pong issue between the two event handlers and my solution is at < http://jsfiddle.net/apandit/nu2rr58h/12/ >. 我用一个标志来解决两个事件处理程序之间的乒乓问题,我的解决方案是在< http://jsfiddle.net/apandit/nu2rr58h/12/ >。

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

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