From: d DOT vrabel AT n-shropshire DOT ac DOT uk (David Vrabel) Newsgroups: comp.os.msdos.djgpp Subject: Re: What does new do when memory is exhausted? Date: Wed, 13 May 1998 13:11:40 GMT Organization: Staffordshire University Lines: 27 Message-ID: <35599b32.1408551@192.168.1.250> References: <35594e81 DOT 4169631 AT 192 DOT 168 DOT 1 DOT 250> <8uh61.2667$z15 DOT 2572850 AT news21 DOT bellglobal DOT com> NNTP-Posting-Host: www.n-shropshire.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk "Paul Derbyshire" wrote: >In GCC 2.8.1, for some unfathomable reason, it prints "Virtual memory exhausted >in new" and dies. >This can be fixed: > >void my_new_handler (void) { throw bad_alloc(); } > >int main (void) { > set_new_handler (my_new_handler); // See relevant C++ docs, e.g. Stroustrup. > /* ... */ > try { > int *foo=new int[len]; > } catch (bad_alloc) { > /* ... */ > } > /* ... */ >} Is it possible to set this up to be the default behavior my modifying some startup file or other? So you don't have to keep doing it in every program? David. David Vrabel d DOT vrabel AT n-shropshire DOT ac DOT uk A poor student (aren't they all) at: North Shropshire College Oswestry, Shropshire, UK