La taille max d'un tableau est effective de :
la taille de ses éléments.
array[0..MAXINT-1] of byte
et sur x64
array[0..MAXDWORD-1] of byte
sont théoriquement faisable ...
ensuite plus les éléments sont "gros" plus il faut réduire le tableau :
exemple :
1 2 3 4 5 6 7 8 9 10 11
|
const
MAXARRAY = 1 shl 30; // 1Go Max
type
TValueA = LongWord;
TValueB = record
A,B,C,D : LongWord;
end;
TArrayA = array[0..(MAXARRAY div SizeOf(TValueA))-1] of TValueA; // 268 435 456 elements / 1Go
TArrayB = array[0..(MAXARRAY div SizeOf(TValueB))-1] of TValueB; // 67 108 864 elements / 1Go |
un exemple made in Borland avec le TPointerList utilisé dans TList :
1 2 3 4 5 6 7
|
const
MaxListSize = Maxint div 16; // 134 217 728 elements max / 512Mo max
type
PPointerList = ^TPointerList;
TPointerList = array[0..MaxListSize - 1] of Pointer; |
autre solutions :
1 2 3 4
|
type
TProfondisArray = packed array[0..0] of Longint;
PProfondisArray = ^TProfondisArray; |
Tel que sont déclaré PChar, PBytes etc.
à utiliser avec AllocMem et FreeMem.
Partager