Paulo de Oliveira Eneas wrote:
> I working in a project that uses a very big struct whose size is approx 4.0 MB.
> If I declare a struct variable within the main (actually, winmain) function I get a stack overflow and the programm crashes. If I declare the structure variable in the global scope, everything goes OK.
Well, I'm not surprised. Very few systems are going to have a stack big
enough to hold a 4 MB structure.
Some will be able to "grow" the stack at need. On those systems, your
program with the struct on the stack "should" work. But maybe not,
because the automatic stack grow routines may not handle a single chunk
that big.
Instead of a global variable, try allocating the structure dynamically.
int main( )
{
DATA* pData;
pData = new DATA;
//...
delete pData;
return 0;
}
Or if you're in C instead of C++,
...
pData = malloc(sizeof(DATA));
...
free(pData);
...
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
