[issue21233] Add *Calloc functions to CPython memory allocation API

STINNER Victor report at bugs.python.org
Sun Apr 27 18:38:51 CEST 2014


STINNER Victor added the comment:

"Because if a code creates many such objects which basically just do
calloc(), on operating systems with memory overommitting (such as
Linux), the calloc() allocations will pretty much always succeed, but
will segfault when the page is first written to in case of low memory."

Overcommit leads to segmentation fault when there is no more memory, but I don't see how calloc() is worse then malloc()+memset(0). It will crash in both cases, no?

In my experience (embedded device with low memory), programs crash because they don't check the result of malloc() (return NULL on allocation failure), not because of overcommit.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21233>
_______________________________________


More information about the Python-bugs-list mailing list