Re: Out of memory?
On 22-Feb-99, 18:19 (CST), John Goerzen <email@example.com> wrote:
> Incidentally, you *REALLY* ought to be mallocing stuff; you can check
> the return code there.
This *may* not be true (in general, I'm not sure about Linux in
particular). Many OS's allow "lazy" allocation of virtual memory; the
memory doesn't actually get reserved until the program tries to use it.
If you allocate 26Mb, and use only 2, it might work; if you try to use
all 26Mb, it will fail. IIRC, the conclusion on comp.std.c was that this
was compliant, or if not, not really something the implementation could
resolve in a useful way. Sorry for not having a reference, or a more
technically accurate description of the problem.
This may also explain why it doesn't segfault until you try to access
it; the startup routines that acquired were told by sbrk() (or whatever)
that it succeeded.