【发布时间】:2021-11-12 19:05:00
【问题描述】:
在 VS2019 (C++ API) 中,相同的代码在 Release 编译下完成,但在 DEBUG 编译下出现错误。
代码如下:
#include "include\DolphinDB.h"
#include "include\Util.h"
#include <iostream>
#include <string>
using namespace dolphindb;
using namespace std;
int main(int argc, char* argv[]) {
string host = "192.168.2.114";
int port = 8848;
string username = "admin";
string password = "123456";
DBConnection conn;
ConstantSP vector;
int size=0;
std::cout << "Connecting DolphinDB: [" << host << ":" << port << "] Username:[" << username << "] Password:[" << password << "]" << endl;
bool ret = conn.connect(host, port,username,password);
if (!ret) {
cout << "Failed to connect to the server" << endl;
//getchar();
//return 0;
goto END_APP;
}
else
{
cout << "Had connected to DolphinDB server [" << host << ":" << port << "] Username=["<<username<<"]\n";
}
//ConstantSP vector = conn.run("`IBM`GOOG`YHOO");
vector = conn.run("today();now()");
size = vector->rows();
for (int i = 0; i < size; ++i)
cout << vector->getString(i) << endl;
END_APP: getchar();
return 0;
}
错误如下:
未处理的异常:Microsoft C++ 异常:std::bad_alloc,位于内存 0x000000B29C97EE30。
【问题讨论】:
-
你有没有通过调试器查看异常是在哪里抛出的?您应该能够在堆栈跟踪中看到是哪一行导致了问题