:Unhandled exception in kernel32.dll 0xc0000005:Access Violation,单步后看是一函数执行完析构时的错误
单步执行,如下代码执行了两次,第一次时无错,监视this为(- this 0x00107ac8 {"270.31994205634 50.00 62.392831294949 10E10 1E-6 0.00 0.00 0.00 "})
第二次时报错。。监视this为(- this 0x00107aec {""})
CString::~CString()
// free any attached data
{
if (GetData() != _afxDataNil)
{
if (InterlockedDecrement(&GetData()->nRefs) <= 0)
FreeData(GetData());
}
}
不知道原因所在
单步执行,如下代码执行了两次,第一次时无错,监视this为(- this 0x00107ac8 {"270.31994205634 50.00 62.392831294949 10E10 1E-6 0.00 0.00 0.00 "})
第二次时报错。。监视this为(- this 0x00107aec {""})
CString::~CString()
// free any attached data
{
if (GetData() != _afxDataNil)
{
if (InterlockedDecrement(&GetData()->nRefs) <= 0)
FreeData(GetData());
}
}
不知道原因所在
搞不懂 有哪些经验可以避免出现内存错误呢