D
doublemaster007
Is that only when system has insufficient memory?? is there any ways
to know why new has failed? (i am on using unix)
to know why new has failed? (i am on using unix)
Is that only when system has insufficient memory??
is there any ways
to know why new has failed? (i am on using unix)
Is that only when system has insufficient memory?? is there any ways
to know why new has failed? (i am on using unix)
Is that only when system has insufficient memory??
is there any ways to know why new has failed?
(i am on using unix)
I am not by any means a Linux expert, but I believe that you are wrongIs that only when system has insufficient memory?? [snip]
(i am on using unix)
You might, but I doubt it. Unix reports the error reason in
errno, but the only documented error for malloc in Posix is
ENOMEM: insufficient storage available.
Note that some Unix, at least by default, don't fail when there
is insufficient memory. (Linux is in this category.) They just
return a pointer which will core dump when you use it.
[snip]You might, but I doubt it. Unix reports the error reason in(i am on using unix)
errno, but the only documented error for malloc in Posix is
ENOMEM: insufficient storage available.
Note that some Unix, at least by default, don't fail when there
is insufficient memory. (Linux is in this category.) They just
return a pointer which will core dump when you use it.
I am not by any means a Linux expert, but I believe that you
are wrong here. Overcommitment of memory is configurable (man
sysconf, if I remember correctly) and look for something like
"overcommit".
If new fails these are the reasons:
1) there is not enough memory available to the program (the system
might have loads of available memory but has limited the memory
available to your program).
2) There is enough memory, but it has been fragmented and can't
allocate a large enough chunk for you.
3) (quite common on comp.lang.c++) you have involved undefined
behaviour, e.g. by accessing memory you should not touch yourself,
causing the memory manager to give erroneous results.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.