How and why an allocation memory can fail?
This was an question I asked myself when I was a student, but failing to
get a satisfying answer, I got it little by little out my mind... till
today.
I known I can deal with an allocation memory error either by checking if
the returned pointer is NULL or by handling the bad_alloc exception.
Ok, but I wonder: How and why the call of new can fail? Up to my
knowledge, an allocation memory can fail if there is not enough space in
the free store. But does this situation really occur nowadays, with
several GB of RAM (at least on a regular computer; I am not talking about
embedded systems)? Can we have other situations where an allocation memory
failure may occur?
No comments:
Post a Comment