enthought / enthought/chaco

Memory Leak when updating axis ranges on the order of 30MB/hour

Open
#406 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
305
Forks
97
PR merge metrics
No merged PRs in 30d

Description

**Problem Description**

![chaco_leak](https://user-images.githubusercontent.com/112847/39472102-029c19e0-4d3f-11e8-8876-ade7b902d302.png)

Updating the the plot data and plot axis range causes a memory leak when manually set. For long-running applications this will eventually crash the process with a `MemoryError` as all memory will be consumed.

The following data shows the leak is dependent on plot refresh rate.

* 60Hz update rate causes leak of *~30MB/hr*
* 30Hz update rate causes leak of *~15MB/hr*

**Reproduction Steps:**

Please see repo. [here](https://github.com/danieljfarrell/ChacoMemoryLeak) with code reproducing the problem and Jupyter notebook for data analysis.

Call the following code in a loop with different x and y data.

```python
# `plot_data` is instance of ArrayPlotData
# `plot` is instance of Plot
# `new_x` and `new_y` are are numpy arrays
plot_data.set_data("x", new_x)
plot_data.set_data("y", new_y)
plot.range2d.x_range.low = new_xmin
plot.range2d.x_range.high = new_xmax
plot.range2d.y_range.low = new_ymin
plot.range2d.y_range.high = new_ymax
```

**Expected behavior:**

Refreshing the plot data should not leak memory; long running applications should not crash with `MemoryError`.

**OS, Python version:**

* Windows 7, Windows 10, Windows Server 2012 R2
* Python 2.7.8
* wx 2.8.12.1
* traits 4.5.0
* traitsui 4.5.1
* chaco 4.5.0
* enable 4.5.1
* kiva 4.5.1
* pyface 4.5.2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.