[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Out of memory?



Brian A May <bmay@dgs.monash.edu.au> writes:

> Hello,
> 
> 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
of segfault?

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 <bmay@csse.monash.edu.au>
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: