Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 May 2004 15:11:48 -0400
From:      Charles Swiger <cswiger@mac.com>
To:        Caroline Korves <ckorves@hotmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: segmentation fault-- is my array too long?
Message-ID:  <394D439E-9F91-11D8-8290-003065ABFD92@mac.com>
In-Reply-To: <BAY8-F110nFxZmS40m300006fb4@hotmail.com>
References:  <BAY8-F110nFxZmS40m300006fb4@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?394D439E-9F91-11D8-8290-003065ABFD92>