David
2015-05-26 12:23:48 UTC
Hi, I seem to have a memory leak while generating a 'live' plot display. This
wasn't the case for GTK2, but the example below is consuming ~800k/second
(Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I
have checked the garbage collector but it doesn't show anything interesting
(no massive incrementing count of uncollected items). Anyway, I would be
very grateful if somebody could confirm and/or fix this (or tell me what I'm
doing wrong).Many thanksDavidCode below:
from gi.repository import Gtk, Gdk, GLibfrom matplotlib.figure import
Figure# Tell matplotlib to use a GTK canvas for drawing#from
matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as
FigureCanvasfrom matplotlib.backends.backend_gtk3cairo import
FigureCanvasGTK3Cairo as FigureCanvas# Application Classclass
pyMatPlotLibTest(object): def update_gui(self): y = [self.index] *
1024 self.index += 1 if self.index > 1024: self.index = 0
Gdk.threads_enter() self.line.set_ydata(y)
self.axes.set_title("%d" % self.index) self.canvas.draw()
Gdk.threads_leave() return True def __init__(self):
self.index = 0 self.x = range(1024) # Initialise the
threads system and allow threads to work with GTK GLib.threads_init()
# Draw scope self.figure = Figure(dpi=100) self.canvas =
FigureCanvas(self.figure) # a Gtk.DrawingArea
#self.widget.alignment_ScopeDisplay.add(self.canvas) # Draw initial
scope self.axes = self.figure.add_subplot(111) self.line, =
self.axes.plot(self.x, [0]* 1024) self.axes.set_title("None")
self.axes.set_xbound(0.0, 1024) self.axes.set_ybound(-16, 1040)
self.window_main = Gtk.Window(title="pyMatPlotLibTest")
self.window_main.connect("destroy", lambda x: Gtk.main_quit())
self.window_main.add(self.canvas) self.window_main.show_all()
# Ticker for the update of the input state monitoring
Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE,
interval = 10, # msec function =
self.update_gui) Gtk.main()if __name__ == "__main__": gui =
pyMatPlotLibTest()
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
wasn't the case for GTK2, but the example below is consuming ~800k/second
(Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I
have checked the garbage collector but it doesn't show anything interesting
(no massive incrementing count of uncollected items). Anyway, I would be
very grateful if somebody could confirm and/or fix this (or tell me what I'm
doing wrong).Many thanksDavidCode below:
from gi.repository import Gtk, Gdk, GLibfrom matplotlib.figure import
Figure# Tell matplotlib to use a GTK canvas for drawing#from
matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as
FigureCanvasfrom matplotlib.backends.backend_gtk3cairo import
FigureCanvasGTK3Cairo as FigureCanvas# Application Classclass
pyMatPlotLibTest(object): def update_gui(self): y = [self.index] *
1024 self.index += 1 if self.index > 1024: self.index = 0
Gdk.threads_enter() self.line.set_ydata(y)
self.axes.set_title("%d" % self.index) self.canvas.draw()
Gdk.threads_leave() return True def __init__(self):
self.index = 0 self.x = range(1024) # Initialise the
threads system and allow threads to work with GTK GLib.threads_init()
# Draw scope self.figure = Figure(dpi=100) self.canvas =
FigureCanvas(self.figure) # a Gtk.DrawingArea
#self.widget.alignment_ScopeDisplay.add(self.canvas) # Draw initial
scope self.axes = self.figure.add_subplot(111) self.line, =
self.axes.plot(self.x, [0]* 1024) self.axes.set_title("None")
self.axes.set_xbound(0.0, 1024) self.axes.set_ybound(-16, 1040)
self.window_main = Gtk.Window(title="pyMatPlotLibTest")
self.window_main.connect("destroy", lambda x: Gtk.main_quit())
self.window_main.add(self.canvas) self.window_main.show_all()
# Ticker for the update of the input state monitoring
Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE,
interval = 10, # msec function =
self.update_gui) Gtk.main()if __name__ == "__main__": gui =
pyMatPlotLibTest()
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html
Sent from the matplotlib - users mailing list archive at Nabble.com.