Open skoudoro opened 1 year ago
It is not just that right? It should be also about resolving some memory management issues.
Or this is for the next PR?
Yes and No @Garyfallidis.
Yes -> it promotes good practice and avoid the memory leak. see below, no memory leak
t = np.linspace(-10, 10, 100)
bundle = []
for i in np.linspace(3, 5, 1000):
pts = np.vstack((np.cos(2 * t/np.pi), np.zeros(t.shape) + i*10, t )).T
bundle.append(pts)
# No memory when show manager outside the loop
showm = window.ShowManager()
for time in range(200):
ren.scene.clear()
bundle_actor = actor.streamtube(bundle, window.colors.red, linewidth=0.01)
showm.scene.add(bundle_actor)
showm.scene.SetBackground(*window.colors.white)
image_array = window.snapshot(
showm, fname='images/file%02d.png' % time, size=(1000, 1000))
No -> the memory leak is from VTK, C++ based, so it will be always there until they fix it. the example below have a memory leak:
t = np.linspace(-10, 10, 100)
bundle = []
for i in np.linspace(3, 5, 1000):
pts = np.vstack((np.cos(2 * t/np.pi), np.zeros(t.shape) + i*10, t )).T
bundle.append(pts)
# ren = window.Scene()
for time in range(200):
# Memory leak here, creation of multiple RenderWindow not well freed by vtk
ren = window.ShowManager()
ren.scene.clear()
bundle_actor = actor.streamtube(bundle, window.colors.red, linewidth=0.01)
ren.scene.add(bundle_actor)
ren.scene.SetBackground(*window.colors.white)
image_array = window.snapshot(
ren, fname='images/file%02d.png' % time, size=(1000, 1000))
This PR is ready to go @Garyfallidis.
2 PR will follow this PR: Update tests, then update tutorials
Unfortunately, there are some issues with viz_timer.py in Ubuntu. Happy to zoom. Hard to explain with words here.
This PR update
snapshot
andrecord
function to allowShowManager
as input argument and deprecateScene
as an input arguments.Many PR will follow-up to clean our tests and tutorial by forcing the use of
ShowManager
196