I solved it.
First of all, the allocated memory on the GPU was not the reason for my performance issues.
However, glumpy can "free" GPU memory by the build in GLObject.deactivate()
method. (I had to write the deactivate() method on the label-renderer agg-glyph-collection myself.
Every GLObject has this method and for me the gloo.Program.deactivate() method solved it by setting the size of the binded buffer to 0.
My issues were caused by the _event_stack
in the app.window.event
class.
You can modify the _event.stack
by attach(event_handler)
and the remove_handlers(handler)
method. If you delete an (shader-)program, the event_handlers are not automatically detached.
It is an event stack, but has also layers (dicts), the remove_handlers
method will find the first layer (frame) where one of the given handlers is attached and delete all occurrence of any given handler but only in this layer/frame.
So for my purpose, the solution was to detach all of my programs separately.
self.program_points.deactivate()
self.skip_plane_program.deactivate()
self.axes_program.deactivate()
self.labels_graph_program.deactivate()
self.labels_axis_program.deactivate()
# this is necessary because glumpy breaks symmetry between push and pop on event_stack
window.remove_handlers(self.program_points['transform'])
window.remove_handlers(self.axes_program['transform'])
window.remove_handlers(self.labels_graph_program['transform'])
window.remove_handlers(self.skip_plane_program['transform'])
window.remove_handlers(self.labels_axis_program['transform'])
This does not work as expected:
window.remove_handlers(self.program_points['transform'], self.axes_program['transform'], self.labels_graph_program['transform'], self.labels_axis_program['transform'])