When I try to use bokeh in Jupyterlab to plot multiple times in a single Output widget, the old bokeh plots appear to stick around in memory even though they aren't actually accessible.
The following code will reproduce the issue (open up chrome's memory profiler and watch the memory increase as you click next).
from bokeh.plotting import figure, output_notebook, show
import ipywidgets as widgets
from ipywidgets import Layout, VBox
output_notebook()
import numpy as np
def plot_sample_bokeh(i):
f = figure(title="test")
f.line(np.arange(100), np.random.randn(100))
show(f)
to_annotate = np.arange(100)
cur_index = 0
def display_img_widget(i):
with out_widget:
plot_sample_bokeh(i)
def on_button_click(b):
global to_annotate, cur_index
cur_id = to_annotate[cur_index]
cur_index += 1
if cur_index == len(to_annotate):
print('End of collection')
return
out_widget.clear_output(wait=True)
display_img_widget(to_annotate[cur_index])
a_button = widgets.Button(description='next', button_style='primary')
a_button.on_click(on_button_click)
out_widget = widgets.Output(width=1100, height=600)
display_img_widget(to_annotate[0])
form_item_layout = Layout(
display='flex',
flex_flow='row',
justify_content='flex-start', width='100%')
form = VBox([a_button, out_widget], layout=form_item_layout)
form
I'm fairly sure that this is a bokeh specific thing (replacing plot_sample_bokeh with an ipywidget.Label doesn't show the same behavior, but that is a pretty simple widget).
When I try to use bokeh in Jupyterlab to plot multiple times in a single Output widget, the old bokeh plots appear to stick around in memory even though they aren't actually accessible.
The following code will reproduce the issue (open up chrome's memory profiler and watch the memory increase as you click next).
I'm fairly sure that this is a bokeh specific thing (replacing
plot_sample_bokeh
with anipywidget.Label
doesn't show the same behavior, but that is a pretty simple widget).jupyterlab: 0.35.4 jupyterlab_bokeh: v0.6.3