I created a C++ program and defined a huge struct. The struct size is
about 10000*100 bytes.
I compiled the program in Borland C++ Builder6 and everything is OK.
However, Visual C++.NET 2003 reported error as "Unhandled exception
at ... Stack overflow". Visual C++ will not report any problem if I
reduce the struct size to a much smaller one. Anybody know how to make
VC++ accept huge struct and not cause stack overflow?
Thank you in advance.
My Struct Sample:
typedef struct
{
double dVarXXX[10000];
}StructYYY;
typedef struct
{
StructYYY myStructYYY[100];
}StructZZZ;
>I created a C++ program and defined a huge struct. The struct size is
>about 10000*100 bytes.
[quoted text clipped - 4 lines]
>reduce the struct size to a much smaller one. Anybody know how to make
>VC++ accept huge struct and not cause stack overflow?
Allocate it on the heap (use new or malloc) rather than on the stack.
Dave
Johnson Liuis - 26 Oct 2007 22:10 GMT
Yes, it works!
> >I created a C++ program and defined a huge struct. The struct size is
>>about 10000*100 bytes.
[quoted text clipped - 8 lines]
>
> Dave
gpsabove@gmail.com - 26 Oct 2007 23:05 GMT
Yes using new or malloc really helps. Thanks.
> Allocate it on the heap (use new or malloc) rather than on the stack.
>
> Dave