At 12:50 PM 7/26/97 +0200, Peter Gerwinski wrote:
>According to Ken:
>>
>> program allo2;
>> var
>> mm: array[1..500000] of real;
>> indx : __long__ integer;
>
>(* JFYI, `__long__ Integer's have 64 bits. For your program, an ordinary
>32-bit `Integer' would be sufficient. *)
>
>> ma: array[1..500000] of real;
>> [...]
>
>> This program realy does nothing of value but when the second FOR
>> loop is running, the program starts eating up memory.
>
>Really at the second FOR loop, not already at the first one?
>I don't know the details of the memory management of Linux, but
>AFAIK, the storage is physically allocated when the array is
>referenced.
>
>> According to TOP,
>> the program uses 8094 kBytes just before the loop ends. Why should
>> this program be so memory hungry at that time? [...]
>
>Simply because one `Real' has eight bytes, and you are allocating one
>million of `Real's. 8000000 bytes are 7812.5kB; if you include code,
>runtime library, etc., 8094kB seems realistic for me.
>
It must be something associated with Linux. I also thought the allocation
of memory should take place when the array is referenced. I stopped the
program with a readln after the first FOR loop and sure enough, ~8108M was
allocated (as seen from top). What is strange is when I run it without the
readln, top shows the allocation to be incremental, not complete after the
first FOR loop like what I see when the readln is in the program...
Thanks...
Ken L.