创建了自定义的非MFC类,无继承。调试时到析构函数结束都没有以上错误跳出,但是过了析构函数后就跳出了这个错误提示,汇编调试窗口显示的出错地址在AfxWinMain入口函数出,不知道是不是因为这个类动态分配内存的缘故,不过我在析构函数了已经销毁了这些动态struct结构阿,百思不得其解。
部分代码:
MIFRestore m_mif;
m_mif.open(filename);//导入文件数据
m_mif.inistance();//将数据动态写入自定义的结构体////////////////////////////////////////
MULTIPOINT结构的写入
///////////////////////////////////////
bool MIFRestore::WriteMifMultipoint(CString str,int &iIndex)
{
CString m_temp;
(m_mifdata.multipoint+count[1])->ID=count[1];
int temp;
temp=atoi(str);

(m_mifdata.multipoint+count[1])->number=temp;
if(temp>1)
{
double *pxy=new double[2*temp];
(m_mifdata.multipoint+count[1])->x=new double[temp];
(m_mifdata.multipoint+count[1])->y=new double[temp];
iIndex++;
str=*(pString+iIndex);
for(int j=1;j<temp;j++)
{
iIndex++;
str=str+' '+*(pString+iIndex);
}
ReDivide(str,pxy);
GetXY(pxy,(m_mifdata.multipoint+count[1])->x,
(m_mifdata.multipoint+count[1])->y,2*temp);
delete[] pxy;
}
else
{
(m_mifdata.multipoint+count[1])->x=new double;
(m_mifdata.multipoint+count[1])->y=new double;
iIndex++;
str=*(pString+iIndex);
double pxy[2];
ReDivide(str,pxy);
(m_mifdata.multipoint+count[1])->x[0]=pxy[0];
(m_mifdata.multipoint+count[1])->y[0]=pxy[1];

}
iIndex++;
str=*(pString+iIndex);
str.TrimLeft();
m_temp=Divide(str);
str.Delete(0,m_temp.GetLength());
str.TrimLeft();
ReDivide(str,style);
(m_mifdata.multipoint+count[1])->point_shape=style[0];
(m_mifdata.multipoint+count[1])->point_color=style[1];
(m_mifdata.multipoint+count[1])->point_size=style[2];
count[1]++;
return true;
}
/////////////////////////////////
析构MUlLTIPOINT结构
////////////////////////////////
if(count[1]>0)
{
for(i=0;i<count[1];i++)
{
if((m_mifdata.multipoint+i)->number>1)
{
delete[] (m_mifdata.multipoint+i)->x;
delete[] (m_mifdata.multipoint+i)->y;
}
        if((m_mifdata.multipoint+i)->number==1)
{
delete (m_mifdata.multipoint+i)->x;
delete (m_mifdata.multipoint+i)->y;
}

}
}
if(i>0)
delete[] m_mifdata.multipoint;

解决方案 »

  1.   

    代码没有看
    不过一定是你的程序引起的
    仔细检查你的new和delete
      

  2.   

    The first-chance exception can be ignored because it is safely handled by the operating system. 
    INFO: First and Second Chance Exception Handling (Q105675)
    Structured exception handling (SEH) takes a little getting used to, particularly when debugging. It is common practice to use SEH as a signaling mechanism. Some application programming interfaces (APIs) register an exception handler in anticipation of a failure condition that is expected to occur in a lower layer. When the exception occurs, the handler may correct or ignore the condition rather than allowing a failure to propagate up through intervening layers. This is very handy in complex environments such as networks where partial failures are expected and it is not desirable to fail an entire operation simply because one of several optional parts failed. In this case, the exception can be handled so that the application is not aware that an exception has occurred. However, if the application is being debugged, it is important to realize that the debugger will see all exceptions before the program does. This is the distinction between the first and second chance exception. The debugger gets the "first chance," hence the name. If the debugger continues the exception unhandled, the program will see the exception as usual. If the program does not handle the exception, the debugger will see it again (the "second chance"). In this latter case, the program normally would have crashed had the debugger not been present. If you do not want to see the first chance exception in the debugger, then disable the feature. Otherwise, during execution, when the debugger gets the first chance, continue the exception unhandled and allow the program to handle the exception as usual. Check the documentation for the debugger that you are using for descriptions of the commands to be used. 
      

  3.   

    http://support.microsoft.com/kb/250563/en-us
      

  4.   

    接楼上的,按照上面MSDN的解释是因为Monitor.exe出问题,可是我的服务里就没见这个进程,改注册表也没看到选项,一筹莫展阿
      

  5.   

    用_CrtDumpMemoryLeaks()检测内存泄露也没有检查出泄露,所以我想这个与new和delete关系不大,不知道诸位怎么看?
      

  6.   

    不一定是内存泄漏引起的
    刚才我写的代码就是简单的读文件,在关闭文件句柄的时候系统NTDLL出错,都是告诉heap出错
    代码本身没有问题,而是读取的文件有问题,读别的文件就没有问题,读该文件就报错