Apparently there is a “malloc_allocator” provided with gcc f开发者_StackOverflowor use with STL. It simply wraps malloc and free. There is also a hook for an out-of-memory handler. Where can I find more about it? Where can I find its header file? I’m using gcc 4.x.
Is this something you want? You will need to include and pass in an object as the STL object's allocator template parameter.
The out-of-memory handler in c++ is defined via set_new_handler
, which might be in the <new>
header, but I'm not sure.
精彩评论