释放std :: vector C++的内存

gis*_*ara 2 c++ mfc stdvector

我有一个矢量如下.

std::vector<std::string> exportNameList;
Run Code Online (Sandbox Code Playgroud)

我通过使用push_back方法向此添加元素.但我得到一个调试断言为"

"Windows已在AxCent.exe中触发了断点.这可能是由于堆损坏,这表明AxCent.exe或其加载的任何DLL中存在错误.

当它调用类的析构函数时会发生这种情况.当我引用调用堆栈时,我被引导到vector类中的以下代码块.

~vector()
{   // destroy the object
    _Tidy();
}
Run Code Online (Sandbox Code Playgroud)

我注意到删除向量时出错.我对么?我该如何解决?我已经提到了很多例子,但是还没有设法解决这个问题.我是C++的新手.

非常感谢.

Ale*_*ler 5

你可能会破坏其他地方的矢量所使用的内存.