How to close or redraw a particular plot - in a jupyter notebook

So, there’s a way to obtain a handle to the plot. Is there a way to close that plot / reset the view in a Jupyter notebook?

handle = show(p, notebook_handle=True)

It’s not to difficult to plot a div and invoke Javascript in a Jupyter notebook on each manual update request, but this approach leaks Chrome memory. There’s got to be a way to close previous handles?

···

On Monday, January 9, 2017 at 6:34:53 PM UTC, [email protected] wrote:

So, there’s a way to obtain a handle to the plot. Is there a way to close that plot / reset the view in a Jupyter notebook?

handle = show(p, notebook_handle=True)

The _CommsHandles are not stored anywhere else that I can see, which means the one returned to you should only have the one reference. Have you tried just calling "del" on any handles you no longer want?

Thanks,

Bryan

···

On Jan 9, 2017, at 1:20 PM, [email protected] wrote:

It's not to difficult to plot a div and invoke Javascript in a Jupyter notebook on each manual update request, but this approach leaks Chrome memory. There's got to be a way to close previous handles?

On Monday, January 9, 2017 at 6:34:53 PM UTC, [email protected] wrote:
So, there's a way to obtain a handle to the plot. Is there a way to close that plot / reset the view in a Jupyter notebook?

handle = show(p, notebook_handle=True)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" 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].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/31385e64-76f9-4c49-9d21-30054a57305e%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Tho, I just noticed you specified Chrome memory. It might be there is a bug/leak to fix on the JS side. The code that handles comms updates is here, in case you want to take a look or have suggestions:

  https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/embed.coffee#L14-L23

In any case, a GH issue to investigate this specifically is probably warranted.

Thanks,

Bryan

···

On Jan 9, 2017, at 1:52 PM, Bryan Van de Ven <[email protected]> wrote:

The _CommsHandles are not stored anywhere else that I can see, which means the one returned to you should only have the one reference. Have you tried just calling "del" on any handles you no longer want?

Thanks,

Bryan

On Jan 9, 2017, at 1:20 PM, [email protected] wrote:

It's not to difficult to plot a div and invoke Javascript in a Jupyter notebook on each manual update request, but this approach leaks Chrome memory. There's got to be a way to close previous handles?

On Monday, January 9, 2017 at 6:34:53 PM UTC, [email protected] wrote:
So, there's a way to obtain a handle to the plot. Is there a way to close that plot / reset the view in a Jupyter notebook?

handle = show(p, notebook_handle=True)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" 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].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/31385e64-76f9-4c49-9d21-30054a57305e%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Yes, I’m profiling Jupyter page using the approach described in https://developers.google.com/web/tools/chrome-devtools/memory-problems/

JS Heap and number of Nodes go up on each redraw. Each redraw is achieved on the Jupyter side by

script, div = components(plot)

div_widget.value = div

display(Javascript(script[35:-9]))

This way no explicit steps are taken to destroy either DOM or JS references.

···

On Monday, January 9, 2017 at 7:55:22 PM UTC, Bryan Van de ven wrote:

Tho, I just noticed you specified Chrome memory. It might be there is a bug/leak to fix on the JS side. The code that handles comms updates is here, in case you want to take a look or have suggestions:

    [https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/embed.coffee#L14-L23](https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/embed.coffee#L14-L23)

In any case, a GH issue to investigate this specifically is probably warranted.

Thanks,

Bryan

On Jan 9, 2017, at 1:52 PM, Bryan Van de Ven [email protected] wrote:

The _CommsHandles are not stored anywhere else that I can see, which means the one returned to you should only have the one reference. Have you tried just calling “del” on any handles you no longer want?

Thanks,

Bryan

On Jan 9, 2017, at 1:20 PM, [email protected] wrote:

It’s not to difficult to plot a div and invoke Javascript in a Jupyter notebook on each manual update request, but this approach leaks Chrome memory. There’s got to be a way to close previous handles?

On Monday, January 9, 2017 at 6:34:53 PM UTC, [email protected] wrote:

So, there’s a way to obtain a handle to the plot. Is there a way to close that plot / reset the view in a Jupyter notebook?

handle = show(p, notebook_handle=True)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” 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].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/31385e64-76f9-4c49-9d21-30054a57305e%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Pav,

We've needed to do an audit of BokehJS memory usage for some time. Truthfully it hasn't happened yet because I am not actually an especially experienced JS developer (I was a C++ and Python dev for 15ish years before working on Bokeh). Do you have any relevant experience in this particular area? Any guidance, help, or suggestions would be appreciated. If there are any low-hanging improvements that can be made I'd love to get them in a dev build ASAP and in 0.12.5 too.

Thanks,

Bryan

···

On Jan 10, 2017, at 4:10 AM, [email protected] wrote:

Yes, I'm profiling Jupyter page using the approach described in https://developers.google.com/web/tools/chrome-devtools/memory-problems/

JS Heap and number of Nodes go up on each redraw. Each redraw is achieved on the Jupyter side by

    script, div = components(plot)
    div_widget.value = div
    display(Javascript(script[35:-9]))

This way no explicit steps are taken to destroy either DOM or JS references.

On Monday, January 9, 2017 at 7:55:22 PM UTC, Bryan Van de ven wrote:
Tho, I just noticed you specified Chrome memory. It might be there is a bug/leak to fix on the JS side. The code that handles comms updates is here, in case you want to take a look or have suggestions:

        https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/embed.coffee#L14-L23

In any case, a GH issue to investigate this specifically is probably warranted.

Thanks,

Bryan

> On Jan 9, 2017, at 1:52 PM, Bryan Van de Ven <[email protected]> wrote:
>
> The _CommsHandles are not stored anywhere else that I can see, which means the one returned to you should only have the one reference. Have you tried just calling "del" on any handles you no longer want?
>
> Thanks,
>
> Bryan
>
>
>> On Jan 9, 2017, at 1:20 PM, [email protected] wrote:
>>
>> It's not to difficult to plot a div and invoke Javascript in a Jupyter notebook on each manual update request, but this approach leaks Chrome memory. There's got to be a way to close previous handles?
>>
>> On Monday, January 9, 2017 at 6:34:53 PM UTC, [email protected] wrote:
>> So, there's a way to obtain a handle to the plot. Is there a way to close that plot / reset the view in a Jupyter notebook?
>>
>> handle = show(p, notebook_handle=True)
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" 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].
>> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/31385e64-76f9-4c49-9d21-30054a57305e%40continuum.io.
>> For more options, visit https://groups.google.com/a/continuum.io/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" 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].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/05601062-b581-4c30-bde6-9ec4296684eb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,
I’m facing the exact same problem of memory consumption on JS side with a data streaming application embedded in a Jupyter notebook. The Chrome dev tools allow to observe a leak each time we close/reopen the bokeh plots of a given cell.

N.

···

On Tuesday, January 10, 2017 at 3:55:21 PM UTC+1, Bryan Van de ven wrote:

Pav,

We’ve needed to do an audit of BokehJS memory usage for some time. Truthfully it hasn’t happened yet because I am not actually an especially experienced JS developer (I was a C++ and Python dev for 15ish years before working on Bokeh). Do you have any relevant experience in this particular area? Any guidance, help, or suggestions would be appreciated. If there are any low-hanging improvements that can be made I’d love to get them in a dev build ASAP and in 0.12.5 too.

Thanks,

Bryan

I believe that some of the recent PRs for 0.12.6 have fixed some of these issue, but there are probably more yet. If you have specific profiling data, it would be valuable. Please share it if you can.

Thanks

Bryan

···

On Jun 13, 2017, at 18:02, nicolas.fr <[email protected]> wrote:

Hi,
I'm facing the exact same problem of memory consumption on JS side with a data streaming application embedded in a Jupyter notebook. The Chrome dev tools allow to observe a leak each time we close/reopen the bokeh plots of a given cell.
N.

On Tuesday, January 10, 2017 at 3:55:21 PM UTC+1, Bryan Van de ven wrote:
Pav,

We've needed to do an audit of BokehJS memory usage for some time. Truthfully it hasn't happened yet because I am not actually an especially experienced JS developer (I was a C++ and Python dev for 15ish years before working on Bokeh). Do you have any relevant experience in this particular area? Any guidance, help, or suggestions would be appreciated. If there are any low-hanging improvements that can be made I'd love to get them in a dev build ASAP and in 0.12.5 too.

Thanks,

Bryan

> On Jan 10, 2017, at 4:10 AM, [email protected] wrote:
>
> Yes, I'm profiling Jupyter page using the approach described in https://developers.google.com/web/tools/chrome-devtools/memory-problems/
>
> JS Heap and number of Nodes go up on each redraw. Each redraw is achieved on the Jupyter side by
>
> script, div = components(plot)
> div_widget.value = div
> display(Javascript(script[35:-9]))
>
> This way no explicit steps are taken to destroy either DOM or JS references.
>
> On Monday, January 9, 2017 at 7:55:22 PM UTC, Bryan Van de ven wrote:
> Tho, I just noticed you specified Chrome memory. It might be there is a bug/leak to fix on the JS side. The code that handles comms updates is here, in case you want to take a look or have suggestions:
>
> https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/embed.coffee#L14-L23
>
> In any case, a GH issue to investigate this specifically is probably warranted.
>
> Thanks,
>
> Bryan
>
>
> > On Jan 9, 2017, at 1:52 PM, Bryan Van de Ven <[email protected]> wrote:
> >
> > The _CommsHandles are not stored anywhere else that I can see, which means the one returned to you should only have the one reference. Have you tried just calling "del" on any handles you no longer want?
> >
> > Thanks,
> >
> > Bryan
> >
> >
> >> On Jan 9, 2017, at 1:20 PM, [email protected] wrote:
> >>
> >> It's not to difficult to plot a div and invoke Javascript in a Jupyter notebook on each manual update request, but this approach leaks Chrome memory. There's got to be a way to close previous handles?
> >>
> >> On Monday, January 9, 2017 at 6:34:53 PM UTC, [email protected] wrote:
> >> So, there's a way to obtain a handle to the plot. Is there a way to close that plot / reset the view in a Jupyter notebook?
> >>
> >> handle = show(p, notebook_handle=True)
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" 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].
> >> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/31385e64-76f9-4c49-9d21-30054a57305e%40continuum.io.
> >> For more options, visit https://groups.google.com/a/continuum.io/d/optout.
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" 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].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/05601062-b581-4c30-bde6-9ec4296684eb%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" 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].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7c1e2ac7-a2d3-46a1-bdb1-dcc935f3cb61%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Bryan,
I will give 0.12.6 a try as soon as it appears on the conda repo.

Concerning the profiling data, so far the main thing I’ve done is to observe the JavaScript memory usage using the Chrome task manager. I also tried to play with the Timeline recording tool but the results are a somewhat difficult to exploit - at least for a JS dummy like me (this is clearly not my world). BTW, I’m still using the code provided to reproduce bokeh issue #6440. The only thing to do is to open/close the plots repeatedly to observe the problem (see first cell of the provided notebook).

N.

···

On Wednesday, June 14, 2017 at 1:04:18 AM UTC+2, Bryan Van de ven wrote:

I believe that some of the recent PRs for 0.12.6 have fixed some of these issue, but there are probably more yet. If you have specific profiling data, it would be valuable. Please share it if you can.

Thanks

Bryan

I just installed 0.12.6 and the open/close leaks are still there.
N.

···

I believe that some of the recent PRs for 0.12.6 have fixed some of these issue, but there are probably more yet.

Hi,

···

On Wed, Jun 14, 2017 at 7:43 AM, nicolas.fr [email protected] wrote:

I just installed 0.12.6 and the open/close leaks are still there.

there is a pretty obvious source of memory leaks in the notebook, which is Bokeh.index accumulating views. Old roots and their views aren’t GCed when a cell is removed or reevaluated. This is a similar issue to what we have (had?) with HTML file output without resetting state between plots.

Mateusz

N.

I believe that some of the recent PRs for 0.12.6 have fixed some of these issue, but there are probably more yet.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” 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].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/c07dbc2b-2e57-4c7f-b993-e0e33a2d779b%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks for the info Mateusz.

I did my best to properly cleanup the content of the curdoc. Since I don’t know how to trigger a callback when a cell output is cleared (1), I have a dedicated ‘close’ button that triggers the cleanup sequence. I’m really not sure that what I’m doing is correct. Is there something I could try? Like emptying curdoc root by root? In fact, my main problem is related to the fact that I really don’t see what a remove_root is supposed to trigger on JS side.

(1) is there even a way to do so? I don’t think so.

···

On Wednesday, June 14, 2017 at 10:26:05 AM UTC+2, mateusz.paprocki wrote:

there is a pretty obvious source of memory leaks in the notebook, which is Bokeh.index accumulating views. Old roots and their views aren’t GCed when a cell is removed or reevaluated. This is a similar issue to what we have (had?) with HTML file output without resetting state between plots.

Mateusz

Bad news I’m afraid. Streaming data (no open/close) seems to also generates leaks. I’m a bit lost…