object freeing related crash?
Posted: Mon Dec 17, 2007 7:51 pm
My code does this for removing active bodies:
and for static line segments.
occasionally I'm getting an error and MSVC says "Windows has triggered a breakpoint, this may indicate a corruption in the heap" or something like that, and points at the freeBins call in this:
Also of note is that i have not noticed this until I added the functionality for moving objects by setting forces on them, however I remove the forces using cpBodyResetForces so I don't see how this could cause it.
I am not freeing and removing the objects in a collision callback. Should I be doing it at some specific time during the simulation loop? currently it's done through the glut mouse callback. Do you think that's a problem? I am still trying to find something specific that I can do to trigger the error.
Code: Select all
cpSpaceRemoveShape(space,shape);
cpSpaceRemoveBody(space,body);
cpBodyFree(body);
cpShapeFree(shape);
Code: Select all
cpSpaceRemoveStaticShape(space,shape);
cpShapeFree(shape);
occasionally I'm getting an error and MSVC says "Windows has triggered a breakpoint, this may indicate a corruption in the heap" or something like that, and points at the freeBins call in this:
Code: Select all
void
cpSpaceHashDestroy(cpSpaceHash *hash)
{
clearHash(hash);
freeBins(hash);
// Free the handles.
cpHashSetEach(hash->handleSet, &handleFreeWrap, NULL);
cpHashSetFree(hash->handleSet);
free(hash->table);
}
I am not freeing and removing the objects in a collision callback. Should I be doing it at some specific time during the simulation loop? currently it's done through the glut mouse callback. Do you think that's a problem? I am still trying to find something specific that I can do to trigger the error.