我正在处理NI DAQmx,它们将无符号定义为uInt32。我在头文件中声明了uInt32数组[1048 * 1024]并进行了编译,但是当我尝试运行它时,它似乎冻结了,而当我停止它时,它退出并出现错误:
The program has unexpectedly finished.
D:\Projects\build-BlackAndWhite12bit-Desktop_Qt_5_1_1_MinGW_32bit-Debug\debug\BlackAndWhite12bit.exe exited with code -1073741571
好吧,这并不是说内存不足,但是由于我分配了4 * 1048 * 1024 = 4,292,608字节,而我的版本是Win7上基于Qt 5.1.1(MSVC 2010,32位)的Qt Creator 2.8.1。 x64,我希望它没有足够的内存。
我发现了一个类似的问题Qt Creator-calloc内存不足,但失败了,但是唯一适用于我的解决方案可能是迁移到64位。但是我该怎么做呢?我尝试从带有Qt 5.2.1 for Windows 64位(VS 2012,556 MB)链接的网站下载该应用程序。但是,当我得到它时,它似乎是为64位配置的32位版本。这是我需要的吗?我需要OpenGL吗?
有没有办法为我当前的Qt版本允许更多的内存?还有其他方法可以解决我的问题吗?
这是.h内容:
#ifndef MAIN12BITSAMPLING_H
#define MAIN12BITSAMPLING_H
#include <QMainWindow>
#include "nivision.h"
#include "nivis.h"
#include "NIDAQmx.h"
namespace Ui {
class main12bitSampling;
}
class main12bitSampling : public QMainWindow
{
Q_OBJECT
public:
explicit main12bitSampling(QWidget *parent = 0);
~main12bitSampling();
...
uInt32 ddata[1073152];
...
signals:
private slots:
private:
Ui::main12bitSampling *ui;
};
#endif // MAIN12BITSAMPLING_H
这是main.c:
#include "main12bitsampling.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
main12bitSampling w;
w.show();
return a.exec();
}
这是main12bitsampling.cpp:
main12bitSampling::main12bitSampling(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::main12bitSampling)
{
ui->setupUi(this);
mainLoop();
}
main12bitSampling::~main12bitSampling()
{
delete ui;
}
-1073741571==0xc00000fd
c00000fd是堆栈溢出的错误代码。
将如此大的数组静态地保留在堆栈中的位置是有问题的,将其分配到堆上,您会得到更好的选择:
QVector<uInt32> ddata;
main12bitSampling::main12bitSampling(QWidget *parent = 0)
QMainWindow(parent), ddata(1024*1048)
{
//...
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句