为什么此代码上升为EXCEPTION_STATK_OVERFLOW
Why this code raise to EXCEPTION_STACK_OVERFLOW?
所以我写代码。
我不明白为什么会出现异常_STACK_OVERFLOW?
#include <iostream>
using namespace std;
int main(){
char data[2048][2048] = {{0}};
cout << "test";
return 0;
}
即使我没有将私有化
char data[2048][2048];
两起案件的情况相同。
Running "main.exe", press ESC to terminate...
Crash
EXCEPTION_STACK_OVERFLOW
time consumed: 0.01 sec
time passed: 0.08 sec
peak memory: 4395008 bytes
您的变量太大,无法将其保留在堆栈中。您应该使用动态存储持续时间。
std::unique_ptr<char[]> data(new char[2048*2048]);
然而,如果您真的想要或必须将其保留在堆栈中,这里有一个gcc标志来更改默认堆栈大小:
--堆栈,4194304其中4194304是以字节为单位的堆栈大小
相关文章:
- 为重写std::exception的库生成swig接口时出错
- 什么是 std::exception::what() 以及为什么要使用它?
- 链表"exception thrown"
- 为什么程序员同时使用 std::bad_alloc 和 std::exception.是否 std::例外 仅是不够的
- C++ broken_promise exception
- 请参阅在 Visual Studio 2019 中捕获 std::exception 时对函数模板实例化消息的引用
- QVTKWidget SetRenderWindow() with PCLVisualizer Exception
- 自定义派生的 std::exception 类的 'what' 函数返回神秘的废话
- 使用flag、return、exception、goto或break中止过程
- 由于某种原因,我的代码中出现了 [json.exception.type_error.302]。我知道错误意味着什么,但我不知道哪里有故障
- 派生自 std::exception 的类的赋值运算符
- 尝试打印字符串时"Python Exception <class 'gdb.error'> There is no member named _M_dataplus."
- std::exception :使用虚函数和继承与变量
- MFC ODBC SQLConfigDataSource() Unhandled Exception
- 这段 C++ 代码的奇怪行为(std::wcout 和 std::exception)
- VTK 7.1.1: vtkX3DExporter exception
- 无法在"catch(const std::exception &ex)"中捕获 std::invalid_argument
- opencv cv::addText exception if no window
- Ctypes: OSError: exception: stack overflow
- C++ CMake 构建错误:未定义对"boost::throw_exception(std::exception const&)"的引用