Hi Niklas,
The version you get with the way you are loading is fairly recent. No
additional work on memory leaks has been done since then. But you should
probably change your loading process to use the new loader by following the
instructions here:
https://developers.google.com/chart/interactive/docs/basic_load_libs#update-library-loader-code
So I am curious to see the details of your code, data and environment,
enough to reproduce the memory leak you are seeing. I can't use the php
code you attached, but just looking at the code, you are regenerating the
chart object every second, but not clearing the previous instance. If you
instead create the chart only one time, and then just draw the chart each
time you have new data, that will at least change things, and might avoid a
memory leak in which each instance of the chart remains bound to the
elements of the document generated to display the chart, if that is still
happening. Alternatively, each time you create a new chart instance, be
sure to explicitly clear and throw away the previous one. You would have
to store the previous chart in a global variable, something like this:
var previousChart;
function drawChart() {
var chart = new google.visualization.SteppedAreaChart(...)
...
if (previousChart) {
previousChart.clearChart();
}
previousChart = chart;
}
The platform you are using (windows, mac, linux) and the version of your
browser could make a difference too.
Hope this helps.
On Fri, Aug 12, 2016 at 5:18 AM, Niklas Nässén <[email protected]> wrote:
> Hello,
>
> My chart is working perfectly, grabbing data from msSQL server every
> second, but the browser memory usage increases by 1Mb per second, causing
> the browser to crash after some hours. I have been looking at old posts
> from 2012-2015 showing workarounds, but I have not been able to implement
> them since I don't understand the explanations of the workarounds
> suggested. For example:
>
> if (chart) {
> chart.clearChart();
> }
>
>
>
> Is there a newer version of the API, then what do I need to change in my
> code to migrate? If not can someone help me in how to make the workarounds
> to work ?
>
> I added some code below that shows the main parts I used. And attached a
> screenshot, and one of the php script I use.
>
> Thanks Nick
>
>
>
>
>
> <script type="text/javascript" src="https://www.google.com/jsapi?autoload=
>
> {'modules':[{'name':'visualization','version':'1.1','packages':
> ['corechart']}]}"></script>
> <script type="text/javascript" >
>
>
>
>
> function getData() {
> jQuery.ajax({
> url: 'ajax_working2.php',
> type: 'GET',
> dataType: 'json',
> mimeType: 'multipart/form-data',
> contentType: false,
> cache: false,
> processData: false,
> success: function(data) {
> if (data == "null") {
>
> } else {
> drawGraph(data);
> }
> },
> error: function(textStatus) {
> console.log(" error.");
> }
> });
> }
>
>
> setInterval(function(){
> document.getElementById("Tiden").innerHTML = new Date().toLocaleString
> ();
> getData();
> },1000);
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to google-visualization-api@
> googlegroups.com.
> Visit this group at https://groups.google.com/
> group/google-visualization-api.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-visualization-api/d6f8d4a6-aeea-452e-9d68-
> f11389c6460e%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/d6f8d4a6-aeea-452e-9d68-f11389c6460e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
[email protected] <[email protected]> 5CC, Cambridge MA
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJNu2NhJFv3HO2SuTvoadeXkDVJF8Hr19u5VKJaq8MP16Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.