Roo*_*ter 2 c++ memory-management segmentation-fault
gdb回溯:
#0 0x0040cea9 in free () from /lib/tls/i686/cmov/libc.so.6
#1 0x0033c741 in operator delete(void*) () from /usr/lib/libstdc++.so.6
#2 0x080654b6 in mesh::calculateMeanNormalsPerVertex (this=0x807d684)
at /home/brent/Desktop/protCAD/src/math/mesh.cc:230
#3 0x0805638f in buildCubes (argc=4, argv=0xbffff3e4)
at /home/brent/Desktop/protCAD/src/driver/executeCubes.cc:163
#4 main (argc=4, argv=0xbffff3e4)
at /home/brent/Desktop/protCAD/src/driver/executeCubes.cc:297
Run Code Online (Sandbox Code Playgroud)
声明并delete致电mesh.cc:
vector<vector<int> > faceIndicesPerVertex (vertexArray.size());
...
delete[] &faceIndicesPerVertex; //line 230
Run Code Online (Sandbox Code Playgroud)
我确定我有这个错误,但我已经尝试了几种不同的方法来调用删除,但除了上面之外似乎没有编译.有什么问题?
您不需要delete任何堆栈分配的对象,vector包括堆栈分配的对象 - 当对象超出范围时,它将被销毁并且其内存将被回收.尝试delete堆栈分配的对象会导致未定义的行为(在您的情况下崩溃).
| 归档时间: |
|
| 查看次数: |
561 次 |
| 最近记录: |