home *** CD-ROM | disk | FTP | other *** search
- program SimpAry;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: SIMPARY }
-
- { This program demonstrates how to create a pointer
- to an array so that you can move it onto the heap
- and out of the data segment. If you put large arrays
- in the data segment, you will soon run out of memory;
- that is, you will overflow the bounds of the data segment.
- There is less than 64K available in the data segment
- of a Windows program, and you cannot afford to
- fill that space up with a few big arrays. As a result,
- you should move most arrays up on the heap, by creating
- pointers to arrays, as shown in this program. }
-
- {$ifDef Windows}
- uses
- WinCrt;
- {$EndIf}
-
- const
- Max = 65000;
-
- type
- PBigArray = ^TBigArray;
- TBigArray = Array[0..Max] of Char;
-
- var
- BigArray: PBigArray;
- i: Word;
-
- begin
- New(BigArray);
-
- for i := 0 To Max do
- BigArray^[i] := 'a';
-
- for i := Max DownTo Max - 10 do
- WriteLn(i, ' => ', BigArray^[i]);
-
- Dispose(BigArray);
- end.
-
-
-
-