In this answer which discusses about the difference between new and malloc states one difference of new from malloc as Can add a new memory allocator to deal with low memory (set_new_handler).
please give a example of this and how it works?
It isn’t exactly a new memory allocator, but a function you can register so that it is called when
operator newruns out of memory.If you can then magically fix the out of memory problem,
newcan try again and see if it works better now. This is most often not very useful, unless your application is holding on to some memory it can release.