Memory leak during updating position of tetrapoly elements

Asked by MikeZhao

There exists sever 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()

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hi Mike,
correct, please report a bug (such that we do not forget about it). Just
now I am not able to say where it comes from..
cheers
Jan

2016-04-14 19:02 GMT+02:00 MikeZhao <email address hidden>:

> New question #290947 on Yade:
> https://answers.launchpad.net/yade/+question/290947
>
> There exists sever 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()
>
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Kneib François (francois-kneib) said :
#2

Hi Mike,
This is a known bug: https://bugs.launchpad.net/yade/+bug/1041084
I wrote recently a couple of C++ functions as a temporary workaround for pos, vel, ori, angVel and color : https://github.com/yade/trunk/commit/71f93009ee9a1dd348c08c269256020eacb2e46a

If you compile Yade from sources, I can write similar functions for mass and inertia if you wish.

François

Revision history for this message
Anton Gladky (gladky-anton) said :
#3

Indeed, those two bugs should be merged.

Anton

2016-04-15 8:03 GMT+02:00 Kneib François <email address hidden>:
> Question #290947 on Yade changed:
> https://answers.launchpad.net/yade/+question/290947
>
> Kneib François proposed the following answer:
> Hi Mike,
> This is a known bug: https://bugs.launchpad.net/yade/+bug/1041084
> I wrote recently a couple of C++ functions as a temporary workaround for pos, vel, ori, angVel and color : https://github.com/yade/trunk/commit/71f93009ee9a1dd348c08c269256020eacb2e46a
>
> If you compile Yade from sources, I can write similar functions for mass
> and inertia if you wish.
>
> François
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp

Revision history for this message
Jan Stránský (honzik) said :
#4

@Francois: it would be nice also for other state variables.

Anyway, the most significant leaks takes place
in O.bodies[0].shape.setVertices(b).

Look at mentioned bug, #8 [1], it was solved by implementing setVertices
for facet. There you pass 3 instances of Vector3, doing no automatic
conversion from tuple/list to std::vector. I will try the same fin this
case.

Jan

[1] https://bugs.launchpad.net/yade/+bug/1041084/comments/8

2016-04-15 8:13 GMT+02:00 Anton Gladky <<email address hidden>
>:

> Question #290947 on Yade changed:
> https://answers.launchpad.net/yade/+question/290947
>
> Anton Gladky proposed the following answer:
> Indeed, those two bugs should be merged.
>
> Anton
>
>
> 2016-04-15 8:03 GMT+02:00 Kneib François <
> <email address hidden>>:
> > Question #290947 on Yade changed:
> > https://answers.launchpad.net/yade/+question/290947
> >
> > Kneib François proposed the following answer:
> > Hi Mike,
> > This is a known bug: https://bugs.launchpad.net/yade/+bug/1041084
> > I wrote recently a couple of C++ functions as a temporary workaround for
> pos, vel, ori, angVel and color :
> https://github.com/yade/trunk/commit/71f93009ee9a1dd348c08c269256020eacb2e46a
> >
> > If you compile Yade from sources, I can write similar functions for mass
> > and inertia if you wish.
> >
> > François
> >
> > --
> > You received this question notification because your team yade-users is
> > an answer contact for Yade.
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~yade-users
> > Post to : <email address hidden>
> > Unsubscribe : https://launchpad.net/~yade-users
> > More help : https://help.launchpad.net/ListHelp
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Jan Stránský (honzik) said :
#5

In the newest trunk version b.shape.setVertices(v1,v2,v3,v4) should work
without memory leaks
cheers
Jan

2016-04-15 10:23 GMT+02:00 Jan Stránský <
<email address hidden>>:

> Question #290947 on Yade changed:
> https://answers.launchpad.net/yade/+question/290947
>
> Jan Stránský proposed the following answer:
> @Francois: it would be nice also for other state variables.
>
> Anyway, the most significant leaks takes place
> in O.bodies[0].shape.setVertices(b).
>
> Look at mentioned bug, #8 [1], it was solved by implementing setVertices
> for facet. There you pass 3 instances of Vector3, doing no automatic
> conversion from tuple/list to std::vector. I will try the same fin this
> case.
>
> Jan
>
> [1] https://bugs.launchpad.net/yade/+bug/1041084/comments/8
>
>
> 2016-04-15 8:13 GMT+02:00 Anton Gladky <
> <email address hidden>
> >:
>
> > Question #290947 on Yade changed:
> > https://answers.launchpad.net/yade/+question/290947
> >
> > Anton Gladky proposed the following answer:
> > Indeed, those two bugs should be merged.
> >
> > Anton
> >
> >
> > 2016-04-15 8:03 GMT+02:00 Kneib François <
> > <email address hidden>>:
> > > Question #290947 on Yade changed:
> > > https://answers.launchpad.net/yade/+question/290947
> > >
> > > Kneib François proposed the following answer:
> > > Hi Mike,
> > > This is a known bug: https://bugs.launchpad.net/yade/+bug/1041084
> > > I wrote recently a couple of C++ functions as a temporary workaround
> for
> > pos, vel, ori, angVel and color :
> >
> https://github.com/yade/trunk/commit/71f93009ee9a1dd348c08c269256020eacb2e46a
> > >
> > > If you compile Yade from sources, I can write similar functions for
> mass
> > > and inertia if you wish.
> > >
> > > François
> > >
> > > --
> > > You received this question notification because your team yade-users is
> > > an answer contact for Yade.
> > >
> > > _______________________________________________
> > > Mailing list: https://launchpad.net/~yade-users
> > > Post to : <email address hidden>
> > > Unsubscribe : https://launchpad.net/~yade-users
> > > More help : https://help.launchpad.net/ListHelp
> >
> > --
> > You received this question notification because your team yade-users is
> > an answer contact for Yade.
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~yade-users
> > Post to : <email address hidden>
> > Unsubscribe : https://launchpad.net/~yade-users
> > More help : https://help.launchpad.net/ListHelp
> >
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Can you help with this problem?

Provide an answer of your own, or ask MikeZhao for more information if necessary.

To post a message you must log in.