{"action":"created","issue":{"url":"https://api.github.com/repos/enthought/chaco/issues/406","repository_url":"https://api.github.com/repos/enthought/chaco","labels_url":"https://api.github.com/repos/enthought/chaco/issues/406/labels{/name}","comments_url":"https://api.github.com/repos/enthought/chaco/issues/406/comments","events_url":"https://api.github.com/repos/enthought/chaco/issues/406/events","html_url":"https://github.com/enthought/chaco/issues/406","id":319180387,"number":406,"title":"Memory Leak when updating axis ranges on the order of 30MB/hour","user":{"login":"danieljfarrell","id":112847,"avatar_url":"https://avatars2.githubusercontent.com/u/112847?v=4","gravatar_id":"","url":"https://api.github.com/users/danieljfarrell","html_url":"https://github.com/danieljfarrell","followers_url":"https://api.github.com/users/danieljfarrell/followers","following_url":"https://api.github.com/users/danieljfarrell/following{/other_user}","gists_url":"https://api.github.com/users/danieljfarrell/gists{/gist_id}","starred_url":"https://api.github.com/users/danieljfarrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieljfarrell/subscriptions","organizations_url":"https://api.github.com/users/danieljfarrell/orgs","repos_url":"https://api.github.com/users/danieljfarrell/repos","events_url":"https://api.github.com/users/danieljfarrell/events{/privacy}","received_events_url":"https://api.github.com/users/danieljfarrell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-05-01T11:56:33Z","updated_at":"2018-05-02T10:56:18Z","closed_at":null,"author_association":"NONE","body":"**Problem Description**\r\n\r\n![chaco_leak](https://user-images.githubusercontent.com/112847/39472102-029c19e0-4d3f-11e8-8876-ade7b902d302.png)\r\n\r\nUpdating 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.\r\n\r\nThe following data shows the leak is dependent on plot refresh rate.\r\n\r\n* 60Hz update rate causes leak of *~30MB/hr*\r\n* 30Hz update rate causes leak of *~15MB/hr*\r\n\r\n**Reproduction Steps:**\r\n\r\nPlease see repo. [here](https://github.com/danieljfarrell/ChacoMemoryLeak) with code reproducing the problem and Jupyter notebook for data analysis.\r\n\r\nCall the following code in a loop with different x and y data.\r\n\r\n```python\r\n        # `plot_data` is instance of ArrayPlotData\r\n        # `plot` is instance of Plot\r\n        # `new_x` and `new_y` are are numpy arrays\r\n        plot_data.set_data(\"x\", new_x)\r\n        plot_data.set_data(\"y\", new_y)\r\n        plot.range2d.x_range.low = new_xmin\r\n        plot.range2d.x_range.high = new_xmax\r\n        plot.range2d.y_range.low = new_ymin\r\n        plot.range2d.y_range.high = new_ymax\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nRefreshing the plot data should not leak memory; long running applications should not crash with `MemoryError`.\r\n\r\n**OS, Python version:**\r\n\r\n* Windows 7, Windows 10, Windows Server 2012 R2\r\n* Python 2.7.8\r\n* wx 2.8.12.1\r\n* traits 4.5.0\r\n* traitsui 4.5.1\r\n* chaco 4.5.0\r\n* enable 4.5.1\r\n* kiva 4.5.1\r\n* pyface 4.5.2\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/enthought/chaco/issues/comments/385939484","html_url":"https://github.com/enthought/chaco/issues/406#issuecomment-385939484","issue_url":"https://api.github.com/repos/enthought/chaco/issues/406","id":385939484,"user":{"login":"corranwebster","id":600761,"avatar_url":"https://avatars3.githubusercontent.com/u/600761?v=4","gravatar_id":"","url":"https://api.github.com/users/corranwebster","html_url":"https://github.com/corranwebster","followers_url":"https://api.github.com/users/corranwebster/followers","following_url":"https://api.github.com/users/corranwebster/following{/other_user}","gists_url":"https://api.github.com/users/corranwebster/gists{/gist_id}","starred_url":"https://api.github.com/users/corranwebster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corranwebster/subscriptions","organizations_url":"https://api.github.com/users/corranwebster/orgs","repos_url":"https://api.github.com/users/corranwebster/repos","events_url":"https://api.github.com/users/corranwebster/events{/privacy}","received_events_url":"https://api.github.com/users/corranwebster/received_events","type":"User","site_admin":false},"created_at":"2018-05-02T10:56:18Z","updated_at":"2018-05-02T10:56:18Z","author_association":"MEMBER","body":"I've played around with this a bit, and I can seem to replicate similar behaviour on Qt and with different backends on OS X.  I haven't compared the rates properly yet, but things seem to be on the same order of magnitude.\r\n\r\nAlthough I don't think that these are the issue here, I'd strongly recommend upgrading to Traits 4.6 as there _have_ been some genuine memory leaks fixed in Traits since Traits 4.5 was released.  Similarly WxPython 2.8 is extremely old; we've just released TraitsUI 6 and I think there is a newer version of Enable and Chaco, and all of these have improvements to stability etc.\r\n\r\nThat said, I don't think any of these is the issue, as I am running on more recent versions of everything and am still seeing some of this behaviour.\r\n\r\nThings which can be ruled out:\r\n\r\n- this is not caused by leaking objects (eg. a refcounting bug somewhere) By looking at `gc.objects()` and forcing garbage collection during the logging step you can see that the total number of Python objects fluctuates but is generally stable.\r\n- this is probably not a WxPython, Traits, or TraitsUI issue, as we are seeing things on different platforms and backends.\r\n- it could still be an issue with the Agg wrapper, most of the backends rely on the Agg wrapper for handling raster images.  We have a new Cython-based Agg wrapper for Kiva so I will have a look seeing if it happens with that backend as well.\r\n\r\nEven with the Chaco UI turned off completely, and also with updates turned off, I am seeing a slow ticking up of memory usage, not at the same rate as with the UI turned on, but it is there.\r\n\r\nSo I am a little bit stumped here.  I will discuss with colleagues here to see if they have any thoughts."}}
{"actor":{"display_login":"corranwebster"}}