使用下列启动:BulletSharp崩溃的应用程序退出
BulletSharp.DefaultCollisionConstructionInfo collisionConstructionInfo =
new BulletSharp.DefaultCollisionConstructionInfo();
BulletSharp.DefaultCollisionConfiguration collisionConfiguration =
new BulletSharp.DefaultCollisionConfiguration(
collisionConstructionInfo);
BulletSharp.Dispatcher collisionDispatcher =
new BulletSharp.CollisionDispatcher(
collisionConfiguration);
BulletSharp.BroadphaseInterface broadPhaseCollisionInterface =
new BulletSharp.SimpleBroadphase();
BulletSharp.CollisionWorld bulletCollisionWorld =
new BulletSharp.CollisionWorld(
collisionDispatcher,
broadPhaseCollisionInterface,
collisionConfiguration);
BulletSharp.ConstraintSolver constraintSolver =
new BulletSharp.SequentialImpulseConstraintSolver();
BulletSharp.DynamicsWorld bulletDynamicsWorld =
new BulletSharp.DiscreteDynamicsWorld(
collisionDispatcher,
broadPhaseCollisionInterface,
constraintSolver,
collisionConfiguration);
运行此六十次第二:
bulletDynamicsWorld.StepSimulation((float)deltaTime, 9, 1.0F/40.0F);
然后调用这些退出一些任意点以后:
Utility.SafeDispose(bulletDynamicsWorld);
Utility.SafeDispose(constraintSolver);
Utility.SafeDispose(broadPhaseCollisionInterface);
Utility.SafeDispose(collisionDispatcher);
Utility.SafeDispose(collisionConfiguration);
Utility.SafeDispose(bulletCollisionWorld); <<< The error happens here >>>
执行突出显示的行时出现以下错误:
“运行时遇到致命错误。错误的地址是线程0x1378上的0x6b1c9704。错误代码是0xc0000005。此错误可能是CLR中的错误,也可能是用户代码中不安全或不可验证的部分。这个bug的常见来源包括COM的互操作或PInvoke的用户编组错误,这可能会损坏堆栈“
注:
1)这是所有子弹代码没有碰撞的对象或动态对象。已被添加。
2)Utility.SafeDispose()需要一个IDiposable,为空值的检查,调用.Dispose()如果有效。
3)语言是C#,要想清楚。
4)Utility.SafeD的位置.SafeDispose语句列表中的ispose(CollisionWorld)似乎没有效果。
为什么它崩溃了,我该如何解决?
谢谢。
'2)Utility.SafeDispose()需要一个IDiposable,检查是否为空值,如果它的有效性是调用.Dispose()。?闻起来像是竞争条件 – asawyer
如何?它与“if(一次性!= null)一次性.Dispose();”没有区别。 –
http://blogs.msdn.com/b/ericlippert/archive/2009/04/29/events-and-races.aspx不是说我说这是你的问题,只是可能要看的东西。 – asawyer