Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!indri!polyslo!ttwang From: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Newsgroups: comp.lang.c++ Subject: Re: proper behavior of operator new Message-ID: <14210@polyslo.CalPoly.EDU> Date: 4 Sep 89 19:09:55 GMT References: <14208@polyslo.CalPoly.EDU> Reply-To: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Distribution: usa Organization: Cal Poly State University -- San Luis Obispo Lines: 20 ttwang@polyslo.CalPoly.EDU (Thomas Wang) writes: >When memory on the free store runs out, operator 'new' will call the function >pointed by _new_handler. When _new_handler finishes, I think the new >operator should try another time to allocate the storage. This is because >the _new_handler may have deleted some unused storage space, so now there >is enough space after all. I just did some testing. The behavior of 'new' is different for cfront 1.2 and g++ 1.34. Cfront will contineously call the _new_handler until some memory is freed. You can set_new_handler(0); to terminate the loop. If enough memory is freed, the object will be allocated with no problem. On the other hand, g++ 1.34 will call _new_handler only once. A null pointer is returned even if enough memory is freed. This looks like a bug. -Thomas Wang ("I am, therefore I am." - Akira ) ttwang@polyslo.calpoly.edu