Memory problem with bokeh server.

I’ve modified a line_animate example to plots more data points. This was done in an attempt to find a memory problem when running the program in a bokeh server.

The program is run using the following:

bokeh serve &

python line_animate.py

The server process stays stable in its memory use, but the python process running the line_animate.py keeps accumulating memory. You can see observe it increasing a few MB per minute.

bokeh: 0.11.1

python 3.5

Mac OSX 10.9.5

Am I doing something wrong? Here’s the modified code

You must first run “bokeh serve” to view this example

import pandas as pd
import numpy as np
from numpy import pi

from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc, ColumnDataSource

data = pd.DataFrame(columns=[‘x’, ‘y1’, ‘y2’])
data.x = np.linspace(0, 4*pi, 600)
data.y1 = np.sin(data.x)
data.y2 = np.cos(data.x)

df = data
p = figure(plot_width=600, plot_height=600,)
r1 = p.circle(source=ColumnDataSource(df), x = ‘x’, y=‘y1’, size=3, color=“navy”, alpha=0.4)
r2 = p.circle(source=ColumnDataSource(df), x = ‘x’, y=‘y2’, size=3, color=“firebrick”, alpha=0.4)

open a session to keep our local document in sync with server

session = push_session(curdoc())

ind = np.arange(len(data))
def update():
global ind
ind = np.roll(ind,1)
df[‘x’] = data.ix[ind, ‘x’].values
r1.data_source.data = ColumnDataSource(df).data
r2.data_source.data = ColumnDataSource(df).data

curdoc().add_periodic_callback(update, 50)

session.show() # open the document in a browser

session.loop_until_closed() # run forever

``

Added issue @ https://github.com/bokeh/bokeh/issues/4007

···

On Monday, March 7, 2016 at 12:02:56 PM UTC-8, waqy wrote:

I’ve modified a line_animate example to plots more data points. This was done in an attempt to find a memory problem when running the program in a bokeh server.

The program is run using the following:

bokeh serve &

python line_animate.py

The server process stays stable in its memory use, but the python process running the line_animate.py keeps accumulating memory. You can see observe it increasing a few MB per minute.

bokeh: 0.11.1

python 3.5

Mac OSX 10.9.5

Am I doing something wrong? Here’s the modified code

You must first run “bokeh serve” to view this example

import pandas as pd
import numpy as np
from numpy import pi

from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc, ColumnDataSource

data = pd.DataFrame(columns=[‘x’, ‘y1’, ‘y2’])
data.x = np.linspace(0, 4*pi, 600)
data.y1 = np.sin(data.x)
data.y2 = np.cos(data.x)

df = data
p = figure(plot_width=600, plot_height=600,)
r1 = p.circle(source=ColumnDataSource(df), x = ‘x’, y=‘y1’, size=3, color=“navy”, alpha=0.4)
r2 = p.circle(source=ColumnDataSource(df), x = ‘x’, y=‘y2’, size=3, color=“firebrick”, alpha=0.4)

open a session to keep our local document in sync with server

session = push_session(curdoc())

ind = np.arange(len(data))
def update():
global ind
ind = np.roll(ind,1)
df[‘x’] = data.ix[ind, ‘x’].values
r1.data_source.data = ColumnDataSource(df).data
r2.data_source.data = ColumnDataSource(df).data

curdoc().add_periodic_callback(update, 50)

session.show() # open the document in a browser

session.loop_until_closed() # run forever

``

I saw a similar issue. Try running the python garbage collection: gc.collect()

This helped me to stabilize the memory growth and get the process to be efficient.

···

On Monday, 7 March 2016 15:02:56 UTC-5, waqy wrote:

I’ve modified a line_animate example to plots more data points. This was done in an attempt to find a memory problem when running the program in a bokeh server.

The program is run using the following:

bokeh serve &

python line_animate.py

The server process stays stable in its memory use, but the python process running the line_animate.py keeps accumulating memory. You can see observe it increasing a few MB per minute.

bokeh: 0.11.1

python 3.5

Mac OSX 10.9.5

Am I doing something wrong? Here’s the modified code

You must first run “bokeh serve” to view this example

import pandas as pd
import numpy as np
from numpy import pi

from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc, ColumnDataSource

data = pd.DataFrame(columns=[‘x’, ‘y1’, ‘y2’])
data.x = np.linspace(0, 4*pi, 600)
data.y1 = np.sin(data.x)
data.y2 = np.cos(data.x)

df = data
p = figure(plot_width=600, plot_height=600,)
r1 = p.circle(source=ColumnDataSource(df), x = ‘x’, y=‘y1’, size=3, color=“navy”, alpha=0.4)
r2 = p.circle(source=ColumnDataSource(df), x = ‘x’, y=‘y2’, size=3, color=“firebrick”, alpha=0.4)

open a session to keep our local document in sync with server

session = push_session(curdoc())

ind = np.arange(len(data))
def update():
global ind
ind = np.roll(ind,1)
df[‘x’] = data.ix[ind, ‘x’].values
r1.data_source.data = ColumnDataSource(df).data
r2.data_source.data = ColumnDataSource(df).data

curdoc().add_periodic_callback(update, 50)

session.show() # open the document in a browser

session.loop_until_closed() # run forever

``