If you are redrawing the whole page by replacing the whole document, that
ought to clear up any memory leak, but old versions of IE used to have
memory leaks even if you did that.

But I suspect you mean the contents of the page body (or some subset) is
redrawn, keeping all the same JavaScript around.  This could accumulate
removed elements and attached event handlers longer than you need.

The proper way to clear the chart is just before you want to delete it from
the page, or replace it with a new one.  That means you would have to store
the chart object somewhere outside of drawAChart.

It would be better if you could use the same elements and even the same
chart objects.  You don't have to recreate all of that just to draw new
versions of the charts with new data or options.  Just call chart.draw()
with the new data or options.


On Sun, Jan 29, 2017 at 6:18 AM, Slugsie <[email protected]> wrote:

> Yes, each minute drawAChart is called for each of the 3 charts. The whole
> page is re-drawn from a controlling routine that is called every minute by
> a setInterval call. There are 3 DIVs on the page, one for each chart. Every
> minute the same 3 DIVs are reused.
>
> When should I be calling chart.clearChart? If I call it after the chart
> has been created then no chart is drawn, but the chartS object only exists
> inside the drawAChart routine, so that's the only place it can be used. Or
> am I missing something?
>
> I think I may try and use some other chart control and see if I get the
> same issues.
>
> On Sunday, 29 January 2017 02:58:07 UTC, Daniel LaLiberte wrote:
>>
>> I would guess you are calling drawAChart more than one time, otherwise
>> there is no reason the memory would grow over time.  Are you keeping the
>> elementDIVs around after you are done with them?  Or is it the same element
>> every time?
>>
>> If you do thrown the unused elements away, then there may still be memory
>> leaks involving event handling bound to those elements.  You can avoid some
>> leaks by clearing the chart that is associated with those elements.
>>  chart.clearChart() is what you want to call.  Ideally, this shouldn't be
>> necessary, but some browsers may still have issues with cleaning up the
>> unused elements, even when they are removed.
>>
>> --
> 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/cc5e0781-3a65-4138-9485-
> 5e7404a75c0b%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/cc5e0781-3a65-4138-9485-5e7404a75c0b%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/CAOtcSJO3T1exA20J5d%3Dyq%3DxSRAA5TOzxG24JbEhVbpOqxBXzdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to