-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak when redrawing graphs #64
Comments
Hmm, when I posted my code example, it wasn't properly escaped, so it didn't show correctly.
|
I've had a hack at this today, and I've added a setData() method to Morris.Line. Take a look at the 'updating' example to see how it works. Currently this is just on the master branch, but I'll include it in the next release (v0.2.10). Let me know if it solves your problem. |
Olly, I tried your fix, and it works great. No signs of memory leaks. Thanks so much. This program has been super helpful to me. |
Tried setData() inside $(window).resize() event handler, it may have cutoffs and misplacement of lines upon redraw. Could you check if setData can maintain proper coordinate for the graph. Also, is there a way to set the graph canvas' width and height? The div container's width and height seems ignored on my end (doesn't matter if it is 50x 50 or 500 x 500) |
Right now there's no code to support resizing the graph, so I'd expect 'odd' behaviour when resizing. Can you send me a jsfiddle that reproduces the container width and height problems you're experiencing? |
I will need to get back to you on this later in the week because I'm a noob with jsfiddles. Still need to set it up. |
Is it possible to dynamically update other options besides the data? |
I have the same question as @schubert1983 "Is it possible to dynamically update other options besides the data?" |
How to get data from SQL ? |
When I call Morris.Line(...) many times within a web page, the browser leaks memory.
I noticed the problem when designing a web page that uses a 1 second timeout to load new data points (via ajax), then I plot the new points using Morris.Line(). Thus the webpage has the appearance of a rolling graph, which looks great. But the browser leaks memory like crazy (1MB/second or more in my project).
Ajax might contribute to the leaks, so I created a simple example with no ajax (html below). My browser leaks around 5MB/minute while viewing the sample. I measure the leaks using Windows Task Manager. I'm running Windows 7 Professional. I see similar leakage rates in Chrome 17.0.963.79 m and Firefox 12.0 .
<title>Real time data</title> <script src="js/jquery-1.7.1.min.js"></script> <script src="js/raphael-2.0.2-min.js"></script> <script src="js/morris.min.js"></script> Graph 0 <script> var nReloads = 0; function draw() { Morris.Line({ element: 'graph0', data: [ {'date': '2012-06-01 15:06:57', 'Apples': 672, 'Bananas': 644, 'Oranges': 185, 'Peaches': 218, 'Pears': 0}, {'date': '2012-06-01 15:06:58', 'Apples': 380, 'Bananas': 259, 'Oranges': 65, 'Peaches': 115, 'Pears': 0}, {'date': '2012-06-01 15:06:59', 'Apples': 305, 'Bananas': 258, 'Oranges': 60, 'Peaches': 132, 'Pears': 0}, {'date': '2012-06-01 15:07:00', 'Apples': 568, 'Bananas': 481, 'Oranges': 137, 'Peaches': 215, 'Pears': 0}, {'date': '2012-06-01 15:07:01', 'Apples': 654, 'Bananas': 538, 'Oranges': 162, 'Peaches': 265, 'Pears': 0}, ], xkey: 'date', ykeys: ['Apples', 'Bananas', 'Oranges', 'Peaches', 'Pears'], labels: ['Apples', 'Bananas', 'Oranges', 'Peaches', 'Pears'], parseTime: false, hideHover: true, ymin: 0, ymax: 'auto 100' }); nReloads++; $('#reloadStatus').text(nReloads + ' reloads'); setTimeout(function() { draw(); }, 1000); } draw(); </script>The text was updated successfully, but these errors were encountered: