Difference static and dynamic allocation on max array size

Difference static and dynamic allocation on max array size

I work on a PIII with 1GB memory + 1Gb SWAP. I am puzzled about my memory usage.

My ulimit -a reads

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited

My maximum array is (according to the compiler)about 2.1 GB, which makes sense given the physical limitations of my
memory. However when I compile

real(kind=4),allocatable,dimension(:,:):: t1
allocate(t1(5000,38233))

then the (5000,38233) is about the maximum size I can get (corresponding to around 765Mb), the machine cries at run-
time that it has not enough virtual memory if make this array any larger. If I do the same but written as

real(kind=4),dimension(5000,107000):: t1

then this is the maximum size I can get without problems. Here I do get the physical limit (~2.1 Gb).

How can I use dynamic allocatation and still use all my physical resources? Why the difference?

Thanks!

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.