← Back to team overview

yade-users team mailing list archive

Re: [Question #657564]: continuous creation and destruction of bodies

 

Question #657564 on Yade changed:
https://answers.launchpad.net/yade/+question/657564

Andrea Puglisi posted a new comment:
Dear Jan
thanks also for your message. Your conclusion is puzzling, i.e. it seems to contradict some statements found in the .cpp and .hpp linked by Jerome above.

Indeed in [2] at line 60 I read  
    "b->id=-1;//else it sits in the python scope without a chance to be inserted again"

And in [1] at line 22 I read

 "Container of bodies implemented as flat std::vector. It handles body removal and
 intelligently reallocates free ids for newly added ones. 
 The nested iterators and the specialized FOREACH_BODY macros above will silently skip null body pointers which may exist after 
 removal. The null pointers can still be accessed via the [] operator. "


One explanation could be that your example is too small, i.e. the engine
of shared_ptr allocation does not reuse old (freed) memory until it is
really necessary, that is after many new insertions. As soon as I have
time I will try to conceive a modification of Jan's example with a much
larger number of bodies deleted and inserted.

Any other ideas?

Thanks a lot to everybody for the prompt help

Andrea


[1] https://github.com/yade/trunk/blob/master/core/BodyContainer.hpp
[2] https://github.com/yade/trunk/blob/master/core/BodyContainer.cpp

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.