Discussion:
Max size array in Delphi
(too old to reply)
elbaid
2004-01-06 07:44:48 UTC
Permalink
Hi,

I want to know the maximum size of an array to be declared in Delphi
(version 5 and up)

I need to manage 12 000 000 combinasions of 6 or 7 numbers (byte) and I
think I must split it in different arrays.

So, someone know this max size ?

Thank you all,
elbaid.
J French
2004-01-06 10:15:38 UTC
Permalink
Post by elbaid
Hi,
I want to know the maximum size of an array to be declared in Delphi
(version 5 and up)
I need to manage 12 000 000 combinasions of 6 or 7 numbers (byte) and I
think I must split it in different arrays.
So, someone know this max size ?
Theoretically the max size is 2gb
ie: No of Elements * Element Size = 2gb

But that is effectively nonsense (I think) as you'll have memory
swapping in and out all over the place

12,000,000 * 6 is approx 72mb

Which strikes me as very large for an Array

Are you sure that you cannot find a way of performing such operations
on disk ?

Generally, if one sorts and organizes ones data, it is possible to get
pretty fast operation without using so much RAM
Bruce Roberts
2004-01-06 16:20:04 UTC
Permalink
Post by elbaid
Hi,
I want to know the maximum size of an array to be declared in Delphi
(version 5 and up)
I need to manage 12 000 000 combinasions of 6 or 7 numbers (byte) and I
think I must split it in different arrays.
So, someone know this max size ?
Presuming a global, i.e. non-stack based, variable its 2 GB as J. French
suggested. (This I believe is more of a 32-bit Windows limitation that one
imposed by Delphi.) If the variable is on the stack then it depends
primarily on your max stack size settings.

I wonder if you really need an array of 12 million bytes. If you simply need
to track usage consider tBits instead. Otherwise, you might consider posting
a brief explanation of what you are trying to achieve. There are often
tradeoffs between storage and process time and there may well be a lower
storage requirement solution available.
elbaid
2004-01-06 19:16:59 UTC
Permalink
Post by Bruce Roberts
Post by elbaid
Hi,
I want to know the maximum size of an array to be declared in Delphi
(version 5 and up)
I need to manage 12 000 000 combinasions of 6 or 7 numbers (byte) and I
think I must split it in different arrays.
So, someone know this max size ?
Presuming a global, i.e. non-stack based, variable its 2 GB as J. French
suggested. (This I believe is more of a 32-bit Windows limitation that one
imposed by Delphi.) If the variable is on the stack then it depends
primarily on your max stack size settings.
I wonder if you really need an array of 12 million bytes. If you simply need
to track usage consider tBits instead. Otherwise, you might consider posting
a brief explanation of what you are trying to achieve. There are often
tradeoffs between storage and process time and there may well be a lower
storage requirement solution available.
I'm trying to simulate a draw (lotto 6/49) with 12M tickets (average
number of tickets sold by draw). It seems that i cannot just simulate
120 000 tickets and extends it to 12M, it isn't really a simulation.

My max stack size is $01000000 (16777216), I conclude this is the max
size in bytes a variable/array can use, right? With experiment I
concluded it is also the max size can be used by all variables...

Thank you (and J French) for your help,
elbaid.
Tom de Neef
2004-01-06 20:01:43 UTC
Permalink
Post by elbaid
I'm trying to simulate a draw (lotto 6/49) with 12M tickets (average
number of tickets sold by draw). It seems that i cannot just simulate
120 000 tickets and extends it to 12M, it isn't really a simulation.
My max stack size is $01000000 (16777216), I conclude this is the max
size in bytes a variable/array can use, right? With experiment I
concluded it is also the max size can be used by all variables...
Thank you (and J French) for your help,
elbaid.
a) There may be no need to have all tickets in memory. If you process them
sequentially, why would you need the ability to go back to one you've
already had? Read them from file.
b) If the array is dynamic (var tickets : array of integer), you may be able
to set a length way beyond the size of the stack.

Tom
Martin Harvey (Demon Account)
2004-01-08 23:01:56 UTC
Permalink
Post by Tom de Neef
a) There may be no need to have all tickets in memory. If you process them
sequentially, why would you need the ability to go back to one you've
already had? Read them from file.
Or even better - if your tickets are generated and processed by your
application, then don't store them at all, just generate a ticket by
whatever method you do, process it, and then discard it. Your storage
requirements then become 1 ticket.

MH.
J French
2004-01-06 20:52:29 UTC
Permalink
On Tue, 06 Jan 2004 14:16:59 -0500, elbaid <***@videotron.com>
wrote:

<snip>
Post by elbaid
I'm trying to simulate a draw (lotto 6/49) with 12M tickets (average
number of tickets sold by draw). It seems that i cannot just simulate
120 000 tickets and extends it to 12M, it isn't really a simulation.
My max stack size is $01000000 (16777216), I conclude this is the max
size in bytes a variable/array can use, right? With experiment I
concluded it is also the max size can be used by all variables...
Thank you (and J French) for your help,
elbaid.
Well thank for your thanks

At the most trivial you have 6 bytes to compare

If you want to get efficient then sort both the two files

www.jerryfrench.co.uk/dsort32.htm

You could speed things up by doing a binary chop
- and with a sorted 'source' file
- a prescient binary chop (ie: one with memory)

HTH
gswork
2004-01-09 09:23:35 UTC
Permalink
Post by elbaid
Post by Bruce Roberts
Post by elbaid
Hi,
I want to know the maximum size of an array to be declared in Delphi
(version 5 and up)
I need to manage 12 000 000 combinasions of 6 or 7 numbers (byte) and I
think I must split it in different arrays.
So, someone know this max size ?
Presuming a global, i.e. non-stack based, variable its 2 GB as J. French
suggested. (This I believe is more of a 32-bit Windows limitation that one
imposed by Delphi.) If the variable is on the stack then it depends
primarily on your max stack size settings.
I wonder if you really need an array of 12 million bytes. If you simply need
to track usage consider tBits instead. Otherwise, you might consider posting
a brief explanation of what you are trying to achieve. There are often
tradeoffs between storage and process time and there may well be a lower
storage requirement solution available.
I'm trying to simulate a draw (lotto 6/49) with 12M tickets (average
number of tickets sold by draw). It seems that i cannot just simulate
120 000 tickets and extends it to 12M, it isn't really a simulation.
If you need to keep the 12m tickets for some later analysis create a
file and read in large chunks for processing.

Really though you could generate tickets on the fly, process the
lottery and analyse the tickets for whatever you may be after (e.g.
std deviation, somthing else?)
Marco van de Voort
2004-01-12 19:26:04 UTC
Permalink
Post by Bruce Roberts
Post by elbaid
Hi,
I want to know the maximum size of an array to be declared in Delphi
(version 5 and up)
I need to manage 12 000 000 combinasions of 6 or 7 numbers (byte) and I
think I must split it in different arrays.
So, someone know this max size ?
Presuming a global, i.e. non-stack based, variable its 2 GB as J. French
suggested. (This I believe is more of a 32-bit Windows limitation that one
imposed by Delphi.)
I think it is a Delphi limitation too. Delphi's base type (integer) is signed, so
the limit is 2^32/2 -1

Loading...