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.
On Mon, 28 Jul 1997, Ken Linder (KC7RAD) wrote:
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).
The memory shows as allocated from top, but no physical allocation or paging occurs untill it's actually referenced. This is to prevent that more memory is allocated by all processes than the total amount of VM.
I know the java runtime allocates > 20M when initializing, but you don't notice anything untill it actually requires this amount of memory...
JJ
--- With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC1925.