Memory leak when updating curve or faces pos values
Closed this issue · 1 comments
Mike Stout reports: I think I have found a solution (at least on Windows) to VPython memory leaks when dynamically updating face (and curve) pos values (possibly also color and normal values).
#surface.pos = ps # Gives memory leak -- fixed by this....
surface.pos[:len(ps)]=ps
Here is his test routine:
from visual import *
def tesselate(ps):
ts = []
for i in range(len(ps)-1):
for j in range(len(ps[0])-1):
vs = [ ps[i][j], ps[i][j+1], ps[i+1][j+1]
, ps[i][j], ps[i+1][j+1], ps[i+1][j] ]
for v in vs: ts.append(v)
vs = [ ps[i][j+1], ps[i][j], ps[i+1][j+1]
, ps[i+1][j+1], ps[i][j], ps[i+1][j] ]
for v in vs: ts.append(v)
return ts
n = 16 # 32
xs = arange(-1,1,2./n)
ys = xs
ps = tesselate([[ (x,0,y) for x in xs ] for y in ys ])
surface = faces(color = color.cyan) # , visible=False)
surface.pos = ps
surface.make_twosided()
def f(p):
(x,z,y),t = p
return (x, .2 * (sin(x_pi + t) + cos(y_pi + t)) , y)
t=0
i = 0
dt = .1
while 1:
t = i*dt
ps = [ f((p,t)) for p in ps]
#surface.pos = ps # Gives memory leak -- fixed by this....
surface.pos[:len(ps)]=ps
surface.make_normals()
surface.smooth()
i += 1
#rate(60)
Fixed by changes to primitives.py