【发布时间】:2014-01-06 08:29:53
【问题描述】:
我编写了一个包含二维向量作为组件的代码。每当我输入时,1/2 秒后它就会显示此错误
"Terminate called after throwing an instance of ‘std::bad_alloc’
What(): std::bad_alloc
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application’s support team for more information."
之后,我的电脑速度变慢,代码返回一个整数,直到我关闭 .exe 文件,它才恢复速度。
这背后的原因是什么?如何避免此类错误?\ 我的代码是http://paste.ubuntu.com/6593192/
【问题讨论】:
-
不提供更多的数据,比如调试结果或者一段源代码,我们一点想法都没有。
-
第一次发布 som 代码:您是否以正确的方式分配指针?你是怎么破坏的?你会循环创建向量吗?
-
你有没有考虑过你的std::vector > 消耗大量内存
标签: c++ debugging error-handling compiler-errors runtime-error