[英]memory leak from vector
I'm seeing I'm getting a memory leak from my vector I have, I've tried deleting the contents then clearing the vector, erasing the vector as well. 我看到我从我的矢量中得到了内存泄漏,我已经尝试删除内容然后清除矢量,也删除了矢量。 My Crtdb is still informing me of memory leaks, I know it involves the vector because when i comment all vector related things i get no leaks.
我的Crtdb仍在通知我内存泄漏,我知道它涉及向量,因为当我评论所有向量相关的东西时,我没有泄漏。 Here is all my code is doing.
这是我的所有代码都在做。
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <vector>
#include "MyClass.h"
int main(void){
Obj *a = new Obj();
std::vector<Obj> vec;
vec.push_back(*a);
Obj b = vec[0];
vec.erase(vec.begin(),vec.end());
delete a;
_CrtDumpMemoryLeaks();
return 0;
}
当你打电话给泄密检查员时,你的矢量还没有超出范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.