我有这样的代码和平:
#include "Item.h"
#include "Object.h"
int main(){
Item Pan(0);
Pan.Prep2Cook();
//Object(char*, int);
Object Drawer(Pan.Oil_Memory, Pan.Oil_Size);
Drawer.Search();
Pan.OilId = Drawer.Oil();
Pan.Finish_Cooking();
return 0;
}
它按预期工作,但如果我将其更改为:
#include "Item.h"
#include "Object.h"
DWORD WINAPI Cooky(LPVOID);
int main(){
// tried changing to 1000000000, still gives the error...
// tried changing to 0, still gives the error...
CreateThread(0,100000,Cooky,LPVOID(0),0,0);
/*...
Do_Other_Stuff();
...*/
return 0;
}
DWORD WINAPI Cooky(LPVOID lParam)
{
Item Pan(int (lParam) );
Pan.Prep2Cook();
Object Drawer(Pan.Oil_Memory, Pan.Oil_Size);//memory allocating error here
Drawer.Search();
Pan.OilId = Drawer.Oil();
Pan.Finish_Cooking();
return 0;
}
在“抽屉”类中分配内存时会出现问题,如下所示:
data1 = new unsigned char[size];//error here
data2 = new unsigned char[size2];
all_data = new unsigned char*[9];
编辑: size 和 size2 等于或小于 10000。
我尝试使用 Createthread 中的 dwStackSize 参数“操纵”,但它仍然给我错误...
欢迎任何有关如何解决此错误的建议。