Re: heap allocation of arrays
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Mon, 19 Jun 2006 12:31:26 -0700
Richard E Maine wrote:
glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:
(snip)Why not just us ALLOCATABLE arrays?
Because sometimes automatics are more convenient. And because I find it
bizzare to choose coding style based on such a criterion. The standard
doesn't hint that this should be a difference between allocatable and
automatic.
(big snip)
Well, to me it depends on where the problem occurs.
As I understand it, C only claims to allow arrays up to 32767.
That is, the standard makes no guarantee past that.
If someone wants to allocate a 100GB array with current technology,
then likely they will have to do something special. The standard may
not say it, but it should be obvious, anyway.
On the other hand, some systems may require the stack size to be
specified at link time. I still remember a Microsoft LINK that
I ran on OS/2 with virtual memory and even larger virtual stack,
but set a default of 2K bytes for stack.
On another hand, many systems are designed around C's allocation,
assuming the use of malloc() for large arrays. (That is, assuming C.)
Since C89 allows only constant length (bounds) for automatic arrays,
it is rare to use them for large arrays. For such systems, malloc()
allocation for automatic arrays would seem an obvious solution.
Still, I believe that for reasonable systems heap allocation should
only be needed for really large arrays. There are still many
unreasonable systems around, though.
You did snip my suggestion for size dependence. Stack allocation
should be more efficient, and cause less fragmentation (of virtual
memory) for smaller arrays.
-- glen
.
- Follow-Ups:
- Re: heap allocation of arrays
- From: Dave Thompson
- Re: heap allocation of arrays
- References:
- heap allocation of arrays
- From: robert . corbett
- Re: heap allocation of arrays
- From: glen herrmannsfeldt
- Re: heap allocation of arrays
- From: Richard E Maine
- heap allocation of arrays
- Prev by Date: Re: Preprocessor for gfortran
- Next by Date: Re: heap allocation of arrays
- Previous by thread: Re: heap allocation of arrays
- Next by thread: Re: heap allocation of arrays
- Index(es):
Relevant Pages
|