TITLE: Writing a "new_handler" PROBLEM: jeffery@flood.com (Jeffery Cavallaro) 2. Are there rules to what _new_handler is supposed to do if it returns. With the BC++ 3.1 compiler it appears that the new operator is re-executed, thus causing the exception again unless the handler has freed something. It seems that the only reasonable thing to do is exit. Any insights here? RESPONSE: steve@taumet.com (Steve Clamage), 9 Dec 92 Vice Chair, ANSI C++ Committee, X3J16 The new_handler function is supplied by you, not by the system. If you arrange for it to be called, you have to be sure it does something that operator new() will find useful. The standard operator new() is supposed to work like this pseudo-code: do { result = get_memory(); if( new_handler && result==0 ) new_handler(); } while( new_handler && result==0 ); return result; If you supply a new_handler routine, it should do something to make memory available. If it can't, it should un-install itself to terminate the above loop. Routines which install the new_handler should therefore not be surprised to find that it has un-installed itself. In addition, you can provide a replacement operator new() which co-operates with the new_handler you also provide. Messing with the memory-management routines is not for the faint of heart. In the C++ Committee we have been working on a specification for the new and delete routines, and on what user replacements for them must do.