max size of automatic arrays?

Eugene D. Brooks III brooks at lll-crg.ARpA
Mon Dec 9 07:26:52 AEST 1985


>main()
>{
>	double humongous[200000];
>	write(2,"A OK\n",5);
>	....
>}
>
>which compiled OK but on an attempt to invoke got me an immediate:
>
>memory fault -- core dumped

I have run into this problem before on Unix systems.  The problem is that the
data is on the stack.  When the stack is expanded slowly, ie through routine
calls with small ammounts of auto data memory faults occur.  The kernel notices
that the fault is close to current stack limit and expands the stack figuring
that the user wants to expand the stack.  If the user however expands the
stack by several meg in one shot, as with a large auto array, the kernel has
no way of knowing that the fault is just a stray pointer and assumes that it
is.  The limit for this change in strategy is probably set in the kernel
somewhere and you could probably change it if you want.



More information about the Comp.unix mailing list