Is there a limit to the amount of memory that can be allocated from a program? By that I mean, is there any protection from a program, for example, that allocates memory in an infinite loop?
When would the call to malloc() return a NULL pointer?
Yes, there is a limit. What that limit is depends on many factors, including (but not limited to):
setrlimit() and the (obsolete) ulimit() function).When memory cannot be allocated, malloc() will return NULL. If the system is completely out of memory, your process may be terminated forcefully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With