大陣列上我在MS VS 2012工作OpenCL和我這樣的代碼:崩潰在C++
cl_float test[480000];
它可以成功地遵守,但程序崩潰時,它進入其上面的代碼是功能英寸錯誤代碼:0xC000041D。
被中斷近的文件 「chkstk.asm」 結尾:
; Find next lower page and probe
cs20:
sub eax, _PAGESIZE_ ; decrease by PAGESIZE
test dword ptr [eax],eax ; probe page.
jmp short cs10
_chkstk endp
end
就行test dword ptr [eax],eax ; probe page.
。我不認爲這個數組太大而不能分配。
所以接下來,我想嘗試另一種方式:
cl_float4 *PixVectIn=(cl_float4*)malloc(480000*sizeof(cl_float4));
for(unsigned int a=0;a<800;a++){
for(unsigned int b=0;b<600;b++){
PixVectIn[a*800+b].x=PixVect[a][b][0];
PixVectIn[a*800+b].y=PixVect[a][b][1];
PixVectIn[a*800+b].z=PixVect[a][b][2];
}
}
該程序還可以建立。這次,運行「for」循環時會崩潰。
它停在PixVectIn[a*800+b].x=PixVect[a][b][0];
。它顯示了相同的錯誤代碼,此時a = 600和b = 252。看起來它到達了一個邊界的東西。
我不確定。這可能是因爲我改變了項目屬性中的某些選項。
對於第一,1MB是一個典型的堆棧大小的限制,並且該陣列是比較大的。對於第二個,600 * 800 + 252大於480000. – immibis
[C++中是否存在最大數組長度限制?](http://stackoverflow.com/a/216731/14065) –