This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Stack frame size


Chin-Pun Teng, wrote:
> I need to compute a matrix with size 3000x3000. However, it seems that
> the C compiler cannot handle it. I got the following message:
>
> Stack frame size (82000048) larger than system limit (67108864)

Geez, you tried to create 82 megabytes' worth of data on the STACK?  No
*wonder* it puked!

The answer is obvious: Don't create the variable on the stack.  Get the
memory for the variable using malloc() instead.  And you better be sure and
check for a NULL pointer afterwards, you are by no means guaranteed to have
82MB free memory at any point.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]