Memory leak during updating position of tetrapoly elements

Bug #1570679 reported by MikeZhao
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Yade
Fix Released
Undecided
Unassigned

Bug Description

There exists severe memory leaking problem when using intermediate variables to update positions of tetraPoly in a loop:

running the code, the memory will keep leaking:
#
a = [[0,0,0],[0,0,1],[0,1,0],[1,0,0]]
O.bodies.append(yade.utils.tetraPoly(a))
for i in range(1000000):
    b = [[0,0,0],[0,0,1],[0,1,0],[i+2,0,0]]
    O.bodies[0].shape.setVertices(b)
    O.bodies[0].state.ori = O.bodies[0].shape.GetOri()
    O.bodies[0].state.pos = O.bodies[0].shape.GetCentroid()
    O.bodies[0].state.mass = O.bodies[0].mat.density * O.bodies[0].shape.GetVolume()
    O.bodies[0].state.inertia = O.bodies[0].mat.density * O.bodies[0].shape.GetInertia()

Revision history for this message
Jan Stránský (honzik) wrote :

setVertices now works without memory leaks passing each vertex as single argument

O.bodies[0].shape.setVertices(b[0],b[1],b[2],b[3])

or

O.bodies[0].shape.setVertices(*b) # *b in Python does internally the above code

currently implemented only for 4 vertices, if needed it is easy to extend to more vertices

Jan

Changed in yade:
status: New → Fix Released
Revision history for this message
Jan Stránský (honzik) wrote :

In previous comment, I meant
O.bodies[0].shape.setVertices(a[0],a[1],a[2],a[3])
O.bodies[0].shape.setVertices(a)
to be consistent with original bug report

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.