comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Question about arrays and no. of elements
Date: Thu, 15 May 2008 16:50:35 GMT
Date: 2008-05-15T16:50:35+00:00	[thread overview]
Message-ID: <vRZWj.339376$cQ1.261796@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: b60e9537-ab45-4856-99de-71127208813f@56g2000hsm.googlegroups.com

Arrays should be created for the number of element used in the 
program with allowances for normal growth of data though the 
lifecycle of the program.  For a array of 10 elements it might be 
easier and more efficient to request an array size that fits on a 
memory page bounds, such as array size that would fit into a 256 
or 512 sector page or a 1 to 4 KB block.

Efficiency of execution depending on how you allocate the array. Plus, 
Array are created before they can be used.

If the compiler creates the million element array then the OS will first 
have to allocate space and load the array into memory (real or virtual), 
if possible. Then the system will load the entire program with array 
into memory.

Now, if array is created during program initialization after loaded into 
memory.  The Ada run-time system will try to allocate the space by 
make a request to the OS for memory, if allocated, the run-time 
simply returns and program continues.  But if memory was not 
allocated then STORAGE_ERROR will be the result.


In <b60e9537-ab45-4856-99de-71127208813f@56g2000hsm.googlegroups.com>, amal.alphonse@gmail.com writes:
>If I define an array with say a million elements, and I only put data
>in 10 of them, is it actually a waste of space/time with the array or
>does Ada only create elements when there is data to put in (so it is
>efficient)?




  parent reply	other threads:[~2008-05-15 16:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 15:19 Question about arrays and no. of elements amal.alphonse
2008-05-15 16:30 ` gautier_niouzes
2008-05-15 16:50 ` anon [this message]
2008-05-15 17:52 ` Adam Beneschan
2008-05-16  9:50 ` Ken Thomas
2008-05-17 14:20 ` Steve
2008-05-17 16:32 ` Jacob Sparre Andersen
2008-05-17 17:37   ` Ludovic Brenta
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox