We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
memory surge after minimizing the vispy window
Hi, thank you very much for working on vispy. Recently, I found a bug related to memory consumption. It appears after minimizing the vispy window, with a memory surge rate of about 50 MB/second. This surge doesn't exist even if you bring other programs to the top level. The only way to trigger it, based on my experience so far, is to minimize the window by either clicking the "Minimize" icon on the window or the taskbar icon of the vispy window. 

Please try the two scripts provided in the Examples folder in the vispy github: Examples\demo\scene\scrolling_plots.py and Examples\demo\gloo\realtime_signals.py

Below is my environment:
OS: Windows 10 ver.1909
Python: 3.8.3
vispy: 0.6.4 or github master
pyqt5: 5.14.2

Thanks! Appreciate the help. 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/demo/gloo/realtime_signals.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # vispy: gallery 2
4 # Copyright (c) Vispy Development Team. All Rights Reserved.
5 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
6 
7 """
8 Multiple real-time digital signals with GLSL-based clipping.
9 """
10 
11 from vispy import gloo
12 from vispy import app
13 import numpy as np
14 import math
15 
16 # Number of cols and rows in the table.
17 nrows = 16
18 ncols = 20
19 
20 # Number of signals.
21 m = nrows*ncols
22 
23 # Number of samples per signal.
24 n = 1000
25 
26 # Various signal amplitudes.
27 amplitudes = .1 + .2 * np.random.rand(m, 1).astype(np.float32)
28 
29 # Generate the signals as a (m, n) array.
30 y = amplitudes * np.random.randn(m, n).astype(np.float32)
31 
32 # Color of each vertex (TODO: make it more efficient by using a GLSL-based
33 # color map and the index).
34 color = np.repeat(np.random.uniform(size=(m, 3), low=.5, high=.9),
35                   n, axis=0).astype(np.float32)
36 
37 # Signal 2D index of each vertex (row and col) and x-index (sample index
38 # within each signal).
39 index = np.c_[np.repeat(np.repeat(np.arange(ncols), nrows), n),
40               np.repeat(np.tile(np.arange(nrows), ncols), n),
41               np.tile(np.arange(n), m)].astype(np.float32)
42 
43 VERT_SHADER = """
44 #version 120
45 
46 // y coordinate of the position.
47 attribute float a_position;
48 
49 // row, col, and time index.
50 attribute vec3 a_index;
51 varying vec3 v_index;
52 
53 // 2D scaling factor (zooming).
54 uniform vec2 u_scale;
55 
56 // Size of the table.
57 uniform vec2 u_size;
58 
59 // Number of samples per signal.
60 uniform float u_n;
61 
62 // Color.
63 attribute vec3 a_color;
64 varying vec4 v_color;
65 
66 // Varying variables used for clipping in the fragment shader.
67 varying vec2 v_position;
68 varying vec4 v_ab;
69 
70 void main() {
71     float nrows = u_size.x;
72     float ncols = u_size.y;
73 
74     // Compute the x coordinate from the time index.
75     float x = -1 + 2*a_index.z / (u_n-1);
76     vec2 position = vec2(x - (1 - 1 / u_scale.x), a_position);
77 
78     // Find the affine transformation for the subplots.
79     vec2 a = vec2(1./ncols, 1./nrows)*.9;
80     vec2 b = vec2(-1 + 2*(a_index.x+.5) / ncols,
81                   -1 + 2*(a_index.y+.5) / nrows);
82     // Apply the static subplot transformation + scaling.
83     gl_Position = vec4(a*u_scale*position+b, 0.0, 1.0);
84 
85     v_color = vec4(a_color, 1.);
86     v_index = a_index;
87 
88     // For clipping test in the fragment shader.
89     v_position = gl_Position.xy;
90     v_ab = vec4(a, b);
91 }
92 """
93 
94 FRAG_SHADER = """
95 #version 120
96 
97 varying vec4 v_color;
98 varying vec3 v_index;
99 
100 varying vec2 v_position;
101 varying vec4 v_ab;
102 
103 void main() {
104     gl_FragColor = v_color;
105 
106     // Discard the fragments between the signals (emulate glMultiDrawArrays).
107     if ((fract(v_index.x) > 0.) || (fract(v_index.y) > 0.))
108         discard;
109 
110     // Clipping test.
111     vec2 test = abs((v_position.xy-v_ab.zw)/v_ab.xy);
112     if ((test.x > 1) || (test.y > 1))
113         discard;
114 }
115 """
116 
117 
118 class Canvas(app.Canvas):
119     def __init__(self):
120         app.Canvas.__init__(self, title='Use your wheel to zoom!',
121                             keys='interactive')
122         self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
123         self.program['a_position'] = y.reshape(-1, 1)
124         self.program['a_color'] = color
125         self.program['a_index'] = index
126         self.program['u_scale'] = (1., 1.)
127         self.program['u_size'] = (nrows, ncols)
128         self.program['u_n'] = n
129 
130         gloo.set_viewport(0, 0, *self.physical_size)
131 
132         self._timer = app.Timer('auto', connect=self.on_timer, start=True)
133 
134         gloo.set_state(clear_color='black', blend=True,
135                        blend_func=('src_alpha', 'one_minus_src_alpha'))
136 
137         self.show()
138 
139     def on_resize(self, event):
140         gloo.set_viewport(0, 0, *event.physical_size)
141 
142     def on_mouse_wheel(self, event):
143         dx = np.sign(event.delta[1]) * .05
144         scale_x, scale_y = self.program['u_scale']
145         scale_x_new, scale_y_new = (scale_x * math.exp(2.5*dx),
146                                     scale_y * math.exp(0.0*dx))
147         self.program['u_scale'] = (max(1, scale_x_new), max(1, scale_y_new))
148         self.update()
149 
150     def on_timer(self, event):
151         """Add some data at the end of each signal (real-time signals)."""
152         k = 10
153         y[:, :-k] = y[:, k:]
154         y[:, -k:] = amplitudes * np.random.randn(m, k)
155 
156         self.program['a_position'].set_data(y.ravel().astype(np.float32))
157         self.update()
158 
159     def on_draw(self, event):
160         gloo.clear()
161         self.program.draw('line_strip')
162 
163 if __name__ == '__main__':
164     c = Canvas()
165     app.run()
166
```

Path: `examples/demo/scene/scrolling_plots.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # Copyright (c) Vispy Development Team. All Rights Reserved.
3 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
4 # vispy: gallery 30
5 """
6 Show 10,000 realtime scrolling plots
7 """
8 from vispy import app, scene
9 import numpy as np
10 
11 
12 canvas = scene.SceneCanvas(keys='interactive', show=True, size=(1024, 768))
13 grid = canvas.central_widget.add_grid()
14 view = grid.add_view(0, 1)
15 view.camera = scene.MagnifyCamera(mag=1, size_factor=0.5, radius_ratio=0.6)
16 
17 # Add axes
18 yax = scene.AxisWidget(orientation='left')
19 yax.stretch = (0.05, 1)
20 grid.add_widget(yax, 0, 0)
21 yax.link_view(view)
22 
23 xax = scene.AxisWidget(orientation='bottom')
24 xax.stretch = (1, 0.05)
25 grid.add_widget(xax, 1, 1)
26 xax.link_view(view)
27 
28 
29 N = 4900
30 M = 2000
31 cols = int(N**0.5)
32 view.camera.rect = (0, 0, cols, N/cols)
33 
34 lines = scene.ScrollingLines(n_lines=N, line_size=M, columns=cols, dx=0.8/M,
35                              cell_size=(1, 8), parent=view.scene)
36 lines.transform = scene.STTransform(scale=(1, 1/8.))
37 
38 
39 def update(ev):
40     m = 50
41     data = np.random.normal(size=(N, m), scale=0.3)
42     data[data > 1] += 4
43     lines.roll_data(data)
44 
45 timer = app.Timer(connect=update, interval=0)
46 timer.start()
47 
48 
49 if __name__ == '__main__':
50     import sys
51     if sys.flags.interactive != 1:
52         app.run()
53
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/examples/demo/gloo/realtime_signals.py b/examples/demo/gloo/realtime_signals.py
--- a/examples/demo/gloo/realtime_signals.py
+++ b/examples/demo/gloo/realtime_signals.py
@@ -155,6 +155,7 @@
 
         self.program['a_position'].set_data(y.ravel().astype(np.float32))
         self.update()
+        self.context.flush()  # prevent memory leak when minimized
 
     def on_draw(self, event):
         gloo.clear()
diff --git a/examples/demo/scene/scrolling_plots.py b/examples/demo/scene/scrolling_plots.py
--- a/examples/demo/scene/scrolling_plots.py
+++ b/examples/demo/scene/scrolling_plots.py
@@ -41,6 +41,7 @@
     data = np.random.normal(size=(N, m), scale=0.3)
     data[data > 1] += 4
     lines.roll_data(data)
+    canvas.context.flush()  # prevent memory leak when minimized
 
 timer = app.Timer(connect=update, interval=0)
 timer.start()

{"golden_diff": "diff --git a/examples/demo/gloo/realtime_signals.py b/examples/demo/gloo/realtime_signals.py\n--- a/examples/demo/gloo/realtime_signals.py\n+++ b/examples/demo/gloo/realtime_signals.py\n@@ -155,6 +155,7 @@\n \n         self.program['a_position'].set_data(y.ravel().astype(np.float32))\n         self.update()\n+        self.context.flush()  # prevent memory leak when minimized\n \n     def on_draw(self, event):\n         gloo.clear()\ndiff --git a/examples/demo/scene/scrolling_plots.py b/examples/demo/scene/scrolling_plots.py\n--- a/examples/demo/scene/scrolling_plots.py\n+++ b/examples/demo/scene/scrolling_plots.py\n@@ -41,6 +41,7 @@\n     data = np.random.normal(size=(N, m), scale=0.3)\n     data[data > 1] += 4\n     lines.roll_data(data)\n+    canvas.context.flush()  # prevent memory leak when minimized\n \n timer = app.Timer(connect=update, interval=0)\n timer.start()\n", "issue": "memory surge after minimizing the vispy window\nHi, thank you very much for working on vispy. Recently, I found a bug related to memory consumption. It appears after minimizing the vispy window, with a memory surge rate of about 50 MB/second. This surge doesn't exist even if you bring other programs to the top level. The only way to trigger it, based on my experience so far, is to minimize the window by either clicking the \"Minimize\" icon on the window or the taskbar icon of the vispy window. \r\n\r\nPlease try the two scripts provided in the Examples folder in the vispy github: Examples\\demo\\scene\\scrolling_plots.py and Examples\\demo\\gloo\\realtime_signals.py\r\n\r\nBelow is my environment:\r\nOS: Windows 10 ver.1909\r\nPython: 3.8.3\r\nvispy: 0.6.4 or github master\r\npyqt5: 5.14.2\r\n\r\nThanks! Appreciate the help. \r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# vispy: gallery 2\n# Copyright (c) Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n\n\"\"\"\nMultiple real-time digital signals with GLSL-based clipping.\n\"\"\"\n\nfrom vispy import gloo\nfrom vispy import app\nimport numpy as np\nimport math\n\n# Number of cols and rows in the table.\nnrows = 16\nncols = 20\n\n# Number of signals.\nm = nrows*ncols\n\n# Number of samples per signal.\nn = 1000\n\n# Various signal amplitudes.\namplitudes = .1 + .2 * np.random.rand(m, 1).astype(np.float32)\n\n# Generate the signals as a (m, n) array.\ny = amplitudes * np.random.randn(m, n).astype(np.float32)\n\n# Color of each vertex (TODO: make it more efficient by using a GLSL-based\n# color map and the index).\ncolor = np.repeat(np.random.uniform(size=(m, 3), low=.5, high=.9),\n                  n, axis=0).astype(np.float32)\n\n# Signal 2D index of each vertex (row and col) and x-index (sample index\n# within each signal).\nindex = np.c_[np.repeat(np.repeat(np.arange(ncols), nrows), n),\n              np.repeat(np.tile(np.arange(nrows), ncols), n),\n              np.tile(np.arange(n), m)].astype(np.float32)\n\nVERT_SHADER = \"\"\"\n#version 120\n\n// y coordinate of the position.\nattribute float a_position;\n\n// row, col, and time index.\nattribute vec3 a_index;\nvarying vec3 v_index;\n\n// 2D scaling factor (zooming).\nuniform vec2 u_scale;\n\n// Size of the table.\nuniform vec2 u_size;\n\n// Number of samples per signal.\nuniform float u_n;\n\n// Color.\nattribute vec3 a_color;\nvarying vec4 v_color;\n\n// Varying variables used for clipping in the fragment shader.\nvarying vec2 v_position;\nvarying vec4 v_ab;\n\nvoid main() {\n    float nrows = u_size.x;\n    float ncols = u_size.y;\n\n    // Compute the x coordinate from the time index.\n    float x = -1 + 2*a_index.z / (u_n-1);\n    vec2 position = vec2(x - (1 - 1 / u_scale.x), a_position);\n\n    // Find the affine transformation for the subplots.\n    vec2 a = vec2(1./ncols, 1./nrows)*.9;\n    vec2 b = vec2(-1 + 2*(a_index.x+.5) / ncols,\n                  -1 + 2*(a_index.y+.5) / nrows);\n    // Apply the static subplot transformation + scaling.\n    gl_Position = vec4(a*u_scale*position+b, 0.0, 1.0);\n\n    v_color = vec4(a_color, 1.);\n    v_index = a_index;\n\n    // For clipping test in the fragment shader.\n    v_position = gl_Position.xy;\n    v_ab = vec4(a, b);\n}\n\"\"\"\n\nFRAG_SHADER = \"\"\"\n#version 120\n\nvarying vec4 v_color;\nvarying vec3 v_index;\n\nvarying vec2 v_position;\nvarying vec4 v_ab;\n\nvoid main() {\n    gl_FragColor = v_color;\n\n    // Discard the fragments between the signals (emulate glMultiDrawArrays).\n    if ((fract(v_index.x) > 0.) || (fract(v_index.y) > 0.))\n        discard;\n\n    // Clipping test.\n    vec2 test = abs((v_position.xy-v_ab.zw)/v_ab.xy);\n    if ((test.x > 1) || (test.y > 1))\n        discard;\n}\n\"\"\"\n\n\nclass Canvas(app.Canvas):\n    def __init__(self):\n        app.Canvas.__init__(self, title='Use your wheel to zoom!',\n                            keys='interactive')\n        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)\n        self.program['a_position'] = y.reshape(-1, 1)\n        self.program['a_color'] = color\n        self.program['a_index'] = index\n        self.program['u_scale'] = (1., 1.)\n        self.program['u_size'] = (nrows, ncols)\n        self.program['u_n'] = n\n\n        gloo.set_viewport(0, 0, *self.physical_size)\n\n        self._timer = app.Timer('auto', connect=self.on_timer, start=True)\n\n        gloo.set_state(clear_color='black', blend=True,\n                       blend_func=('src_alpha', 'one_minus_src_alpha'))\n\n        self.show()\n\n    def on_resize(self, event):\n        gloo.set_viewport(0, 0, *event.physical_size)\n\n    def on_mouse_wheel(self, event):\n        dx = np.sign(event.delta[1]) * .05\n        scale_x, scale_y = self.program['u_scale']\n        scale_x_new, scale_y_new = (scale_x * math.exp(2.5*dx),\n                                    scale_y * math.exp(0.0*dx))\n        self.program['u_scale'] = (max(1, scale_x_new), max(1, scale_y_new))\n        self.update()\n\n    def on_timer(self, event):\n        \"\"\"Add some data at the end of each signal (real-time signals).\"\"\"\n        k = 10\n        y[:, :-k] = y[:, k:]\n        y[:, -k:] = amplitudes * np.random.randn(m, k)\n\n        self.program['a_position'].set_data(y.ravel().astype(np.float32))\n        self.update()\n\n    def on_draw(self, event):\n        gloo.clear()\n        self.program.draw('line_strip')\n\nif __name__ == '__main__':\n    c = Canvas()\n    app.run()\n", "path": "examples/demo/gloo/realtime_signals.py"}, {"content": "# -*- coding: utf-8 -*-\n# Copyright (c) Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# vispy: gallery 30\n\"\"\"\nShow 10,000 realtime scrolling plots\n\"\"\"\nfrom vispy import app, scene\nimport numpy as np\n\n\ncanvas = scene.SceneCanvas(keys='interactive', show=True, size=(1024, 768))\ngrid = canvas.central_widget.add_grid()\nview = grid.add_view(0, 1)\nview.camera = scene.MagnifyCamera(mag=1, size_factor=0.5, radius_ratio=0.6)\n\n# Add axes\nyax = scene.AxisWidget(orientation='left')\nyax.stretch = (0.05, 1)\ngrid.add_widget(yax, 0, 0)\nyax.link_view(view)\n\nxax = scene.AxisWidget(orientation='bottom')\nxax.stretch = (1, 0.05)\ngrid.add_widget(xax, 1, 1)\nxax.link_view(view)\n\n\nN = 4900\nM = 2000\ncols = int(N**0.5)\nview.camera.rect = (0, 0, cols, N/cols)\n\nlines = scene.ScrollingLines(n_lines=N, line_size=M, columns=cols, dx=0.8/M,\n                             cell_size=(1, 8), parent=view.scene)\nlines.transform = scene.STTransform(scale=(1, 1/8.))\n\n\ndef update(ev):\n    m = 50\n    data = np.random.normal(size=(N, m), scale=0.3)\n    data[data > 1] += 4\n    lines.roll_data(data)\n\ntimer = app.Timer(connect=update, interval=0)\ntimer.start()\n\n\nif __name__ == '__main__':\n    import sys\n    if sys.flags.interactive != 1:\n        app.run()\n", "path": "examples/demo/scene/scrolling_plots.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# vispy: gallery 2\n# Copyright (c) Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n\n\"\"\"\nMultiple real-time digital signals with GLSL-based clipping.\n\"\"\"\n\nfrom vispy import gloo\nfrom vispy import app\nimport numpy as np\nimport math\n\n# Number of cols and rows in the table.\nnrows = 16\nncols = 20\n\n# Number of signals.\nm = nrows*ncols\n\n# Number of samples per signal.\nn = 1000\n\n# Various signal amplitudes.\namplitudes = .1 + .2 * np.random.rand(m, 1).astype(np.float32)\n\n# Generate the signals as a (m, n) array.\ny = amplitudes * np.random.randn(m, n).astype(np.float32)\n\n# Color of each vertex (TODO: make it more efficient by using a GLSL-based\n# color map and the index).\ncolor = np.repeat(np.random.uniform(size=(m, 3), low=.5, high=.9),\n                  n, axis=0).astype(np.float32)\n\n# Signal 2D index of each vertex (row and col) and x-index (sample index\n# within each signal).\nindex = np.c_[np.repeat(np.repeat(np.arange(ncols), nrows), n),\n              np.repeat(np.tile(np.arange(nrows), ncols), n),\n              np.tile(np.arange(n), m)].astype(np.float32)\n\nVERT_SHADER = \"\"\"\n#version 120\n\n// y coordinate of the position.\nattribute float a_position;\n\n// row, col, and time index.\nattribute vec3 a_index;\nvarying vec3 v_index;\n\n// 2D scaling factor (zooming).\nuniform vec2 u_scale;\n\n// Size of the table.\nuniform vec2 u_size;\n\n// Number of samples per signal.\nuniform float u_n;\n\n// Color.\nattribute vec3 a_color;\nvarying vec4 v_color;\n\n// Varying variables used for clipping in the fragment shader.\nvarying vec2 v_position;\nvarying vec4 v_ab;\n\nvoid main() {\n    float nrows = u_size.x;\n    float ncols = u_size.y;\n\n    // Compute the x coordinate from the time index.\n    float x = -1 + 2*a_index.z / (u_n-1);\n    vec2 position = vec2(x - (1 - 1 / u_scale.x), a_position);\n\n    // Find the affine transformation for the subplots.\n    vec2 a = vec2(1./ncols, 1./nrows)*.9;\n    vec2 b = vec2(-1 + 2*(a_index.x+.5) / ncols,\n                  -1 + 2*(a_index.y+.5) / nrows);\n    // Apply the static subplot transformation + scaling.\n    gl_Position = vec4(a*u_scale*position+b, 0.0, 1.0);\n\n    v_color = vec4(a_color, 1.);\n    v_index = a_index;\n\n    // For clipping test in the fragment shader.\n    v_position = gl_Position.xy;\n    v_ab = vec4(a, b);\n}\n\"\"\"\n\nFRAG_SHADER = \"\"\"\n#version 120\n\nvarying vec4 v_color;\nvarying vec3 v_index;\n\nvarying vec2 v_position;\nvarying vec4 v_ab;\n\nvoid main() {\n    gl_FragColor = v_color;\n\n    // Discard the fragments between the signals (emulate glMultiDrawArrays).\n    if ((fract(v_index.x) > 0.) || (fract(v_index.y) > 0.))\n        discard;\n\n    // Clipping test.\n    vec2 test = abs((v_position.xy-v_ab.zw)/v_ab.xy);\n    if ((test.x > 1) || (test.y > 1))\n        discard;\n}\n\"\"\"\n\n\nclass Canvas(app.Canvas):\n    def __init__(self):\n        app.Canvas.__init__(self, title='Use your wheel to zoom!',\n                            keys='interactive')\n        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)\n        self.program['a_position'] = y.reshape(-1, 1)\n        self.program['a_color'] = color\n        self.program['a_index'] = index\n        self.program['u_scale'] = (1., 1.)\n        self.program['u_size'] = (nrows, ncols)\n        self.program['u_n'] = n\n\n        gloo.set_viewport(0, 0, *self.physical_size)\n\n        self._timer = app.Timer('auto', connect=self.on_timer, start=True)\n\n        gloo.set_state(clear_color='black', blend=True,\n                       blend_func=('src_alpha', 'one_minus_src_alpha'))\n\n        self.show()\n\n    def on_resize(self, event):\n        gloo.set_viewport(0, 0, *event.physical_size)\n\n    def on_mouse_wheel(self, event):\n        dx = np.sign(event.delta[1]) * .05\n        scale_x, scale_y = self.program['u_scale']\n        scale_x_new, scale_y_new = (scale_x * math.exp(2.5*dx),\n                                    scale_y * math.exp(0.0*dx))\n        self.program['u_scale'] = (max(1, scale_x_new), max(1, scale_y_new))\n        self.update()\n\n    def on_timer(self, event):\n        \"\"\"Add some data at the end of each signal (real-time signals).\"\"\"\n        k = 10\n        y[:, :-k] = y[:, k:]\n        y[:, -k:] = amplitudes * np.random.randn(m, k)\n\n        self.program['a_position'].set_data(y.ravel().astype(np.float32))\n        self.update()\n        self.context.flush()  # prevent memory leak when minimized\n\n    def on_draw(self, event):\n        gloo.clear()\n        self.program.draw('line_strip')\n\nif __name__ == '__main__':\n    c = Canvas()\n    app.run()\n", "path": "examples/demo/gloo/realtime_signals.py"}, {"content": "# -*- coding: utf-8 -*-\n# Copyright (c) Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# vispy: gallery 30\n\"\"\"\nShow 10,000 realtime scrolling plots\n\"\"\"\nfrom vispy import app, scene\nimport numpy as np\n\n\ncanvas = scene.SceneCanvas(keys='interactive', show=True, size=(1024, 768))\ngrid = canvas.central_widget.add_grid()\nview = grid.add_view(0, 1)\nview.camera = scene.MagnifyCamera(mag=1, size_factor=0.5, radius_ratio=0.6)\n\n# Add axes\nyax = scene.AxisWidget(orientation='left')\nyax.stretch = (0.05, 1)\ngrid.add_widget(yax, 0, 0)\nyax.link_view(view)\n\nxax = scene.AxisWidget(orientation='bottom')\nxax.stretch = (1, 0.05)\ngrid.add_widget(xax, 1, 1)\nxax.link_view(view)\n\n\nN = 4900\nM = 2000\ncols = int(N**0.5)\nview.camera.rect = (0, 0, cols, N/cols)\n\nlines = scene.ScrollingLines(n_lines=N, line_size=M, columns=cols, dx=0.8/M,\n                             cell_size=(1, 8), parent=view.scene)\nlines.transform = scene.STTransform(scale=(1, 1/8.))\n\n\ndef update(ev):\n    m = 50\n    data = np.random.normal(size=(N, m), scale=0.3)\n    data[data > 1] += 4\n    lines.roll_data(data)\n    canvas.context.flush()  # prevent memory leak when minimized\n\ntimer = app.Timer(connect=update, interval=0)\ntimer.start()\n\n\nif __name__ == '__main__':\n    import sys\n    if sys.flags.interactive != 1:\n        app.run()\n", "path": "examples/demo/scene/scrolling_plots.py"}]}