segmentation fault-- is my array too long?

Charles Swiger cswiger at mac.com
Thu May 6 12:11:56 PDT 2004


This doesn't have much to do with FreeBSD, but...

On May 6, 2004, at 2:58 PM, Caroline Korves wrote:
> Any idea on what I should change to make the program run with large
> numbers of elements in my arrays?

Automatic variables get allocated from the stack, which can only grow 
to handle 8 MB or so by default.  If you dynamicly allocate these 
arrays using malloc(), or else add the "static" keyword before the 
following declarations, you can probably increase the size of persons 
by a factor of 10 or more:

>    double ncost[persons][scens];
>    double nuts[persons][scens];

-- 
-Chuck



More information about the freebsd-questions mailing list