Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 调用delete会导致C++;冻结程序_C++_Delete Operator - Fatal编程技术网

C++ 调用delete会导致C++;冻结程序

C++ 调用delete会导致C++;冻结程序,c++,delete-operator,C++,Delete Operator,还有一件事我不想做,我进行了拆卸,并能够继续进行,直到: GameObject::~GameObject() { //Delete each component using the component's virtual destructor //takes care of all resources and memory. for( ComponentMapIt it = componentMap.begin();it!=componentMap.end();++it) d

还有一件事我不想做,我进行了拆卸,并能够继续进行,直到:

GameObject::~GameObject()
{
  //Delete each component using the component's virtual destructor
  //takes care of all resources and memory.
  for( ComponentMapIt it = componentMap.begin();it!=componentMap.end();++it)
    delete it->second;
}
然后它就挂了,没有别的事情发生

编辑:这是我的新手错误。出于某种原因,我无法进入delete调用,所以我假设它在那里,但在其中添加断点使我能够进入它。谢谢大家,你们的建议都很有帮助

00488DA9  call        GameObject::`scalar deleting destructor' (044055Fh)  
void PhysicsManager::注销(刚体*Obj)
{
std::list::iterator it=MasterList.begin();
while(it!=MasterList.end())
{
如果(*it==Obj)
{
主列表。删除(它);
返回;
}
}
}
void PhysicsManager::注销(刚体*Obj)
{
std::list::iterator it=MasterList.begin();
while(it!=MasterList.end())
{
如果(*it==Obj)
{
主列表。删除(它);
返回;
}
}
}

它是恒定的,永远不会改变:一旦循环开始,*它!=Obj循环将永远持续

在哪一行冻结?错误消息不应该是“内存不好,宇宙射线位翻转或双重删除错误!”吗?嗨,我发布了一个问题,它冻结在第15行,即“删除对象”。你可能碰到了阻碍进一步处理的东西,例如析构函数中的无限循环或某种锁定机制。~GameObject()本身似乎没有什么问题,但它所删除的对象的析构函数(以及那些对象析构函数正在删除的任何对象,等等)可能会“卡住”。我猜你是在试图释放你不拥有的内存,还是在试图释放你已经释放的内存。你能试着把你的代码缩减到一个合理简短的可复制的例子吗?
00488DA9  call        GameObject::`scalar deleting destructor' (044055Fh)  
void PhysicsManager::Unregister(RigidBody *Obj)
{
  std::list<RigidBody*>::iterator it = MasterList.begin();

  while(it != MasterList.end())
  {
    if(*it == Obj)
    {
      MasterList.erase(it);
      return;
    }
  }
}
void PhysicsManager::Unregister(RigidBody *Obj)
{
  std::list<RigidBody*>::iterator it = MasterList.begin();

  while(it != MasterList.end())
  {
    if(*it == Obj)
    {
      MasterList.erase(it);
      return;
    }
  }
}