堆腐败C ++
试图编译我的程序时,我收到堆损坏错误。 有问题的代码是一个指针
cparticle * particles.
它被初始化为NULL,然后设置为
particles = new cparticle[amount]
我只在析构函数中使用了一次删除操作,并导致窗口触发断点。 我试图使用应用程序验证器,它给了我这个信息:
===========================================================
VERIFIER STOP 0000000000000013: pid 0x17C0: first chance access violation for current stack trace
000000001D54A0A4 : Invalid address being accessed
0000000055741DC6 : Code performing invalid access
000000000025E9D0 : Exception record. Use .exr to display it.
000000000025E4E0 : Context record. Use .cxr to display it.
===========================================================
This verifier stop is continuable.
After debugging it use `go' to continue.
===========================================================
=======================================
VERIFIER STOP 00000013: pid 0x17C0: First chance access violation for current stack trace.
1D54A0A4 : Invalid address causing the exception.
55741DC6 : Code address executing the invalid access.
001DF30C : Exception record.
001DF35C : Context record.
=======================================
This verifier stop is continuable.
After debugging it use `go' to continue.
=======================================
我不确定我做错了什么,所以任何帮助将不胜感激。
你做错的第一件事是你没有使用std::vector<particle>
。
第二件事大概是,你正在记忆你的粒子阵列的末端。
你是否在一个小型的独立程序中重现了这一点? 你确定它不是由之前未被发现的其他内存违规引起的吗? 你使用了正确的删除操作符吗?
链接地址: http://www.djcxy.com/p/82481.html上一篇: Heap corruption C++
下一篇: How can I overload the new operator to allocate on the stack?