Re: Out of memory?
Brian A May <email@example.com> writes:
> What is the expected reponse when running a C program that allocates more
> memory (as static arrays) then the system can provide?
To be 100% precise, more virtual memory than it can provide (it will
try swap too).
> I would have expected that the linux kernel would give an out-of memory error
> message, as I believe it is the kernels job to allocate memory for
> static variables. (either that or the startup code in the C program).
Well, the kernel handles the request, but really the system is not out
of memory, just one userspace program.
> However, when I run such a program, I get a "segmentation fault" when
> the program attempts to access a global variable.
> Is this correct? Is this normal behaviour?
I would have expected it to segfault before it even got to main, hmm.
Are you sure this is the problem? What does gdb say about the point
Incidentally, you *REALLY* ought to be mallocing stuff; you can check
the return code there.
> I have a fully up-to-date slink system, and am using linux 2.2.1
> Brian May <firstname.lastname@example.org>
> To UNSUBSCRIBE, email to email@example.com
> with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org