[ODE] memory leak fix for dxGeom class

Geoff Carlton gcarlton at iinet.net.au
Thu Apr 27 16:50:31 MST 2006


Hi,
This logic is correct.  Looks like a bug that slipped through when I 
wrote the offset geom code, so the patch should be applied ASAP.

Thanks,
Geoff

Paul MacKenzie wrote:
> Hi,
>
> I found a memory leak in the destructor for the dxGeom class, in 
> collision_kernel.cpp, and submitted a solution as a patch under the name 
> "Memory leak fix for dxGeom".
>
> Currently the destructor is
>
> dxGeom::~dxGeom()
> {
>    if (parent_space) dSpaceRemove (parent_space,this);
>    if ((gflags & GEOM_PLACEABLE) && !body) dFreePosr(final_posr);
>    if (offset_posr) dFreePosr(offset_posr);
>    bodyRemove();
> }
>
> However, if the collision geometry has an associated body *and* an 
> offset, then it has its own allocated final_posr, and it should be freed 
> here in the destructor.  If it has an associated body and *no* offset, 
> then final_posr points to the body and should not be deleted (refer to 
> dGeomSetBody() and dGeomCreateOffset() for details on how this works).
>
> Here is a solution that removes the leak:
>
> dxGeom::~dxGeom()
> {
>    if (parent_space) dSpaceRemove (parent_space,this);
>    if ((gflags & GEOM_PLACEABLE) && (!body || (body && offset_posr)))
>      dFreePosr(final_posr);
>    if (offset_posr) dFreePosr(offset_posr);
>    bodyRemove();
> }
>
> Cheers,
> Paul
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
>
>   


More information about the ODE mailing list