Click here to Skip to main content
15,907,396 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: operator new and CObject Pin
Mark Salsbery18-Jun-07 11:33
Mark Salsbery18-Jun-07 11:33 
GeneralRe: operator new and CObject Pin
bob1697218-Jun-07 12:01
bob1697218-Jun-07 12:01 
GeneralRe: operator new and CObject Pin
Mark Salsbery18-Jun-07 12:11
Mark Salsbery18-Jun-07 12:11 
GeneralRe: operator new and CObject Pin
Bram van Kampen18-Jun-07 14:45
Bram van Kampen18-Jun-07 14:45 
GeneralRe: operator new and CObject Pin
bob1697218-Jun-07 15:00
bob1697218-Jun-07 15:00 
GeneralRe: operator new and CObject Pin
Mark Salsbery18-Jun-07 13:11
Mark Salsbery18-Jun-07 13:11 
GeneralRe: operator new and CObject Pin
bob1697218-Jun-07 15:08
bob1697218-Jun-07 15:08 
GeneralRe: operator new and CObject Pin
Mark Salsbery18-Jun-07 15:27
Mark Salsbery18-Jun-07 15:27 
bob16972 wrote:
I didn't walk away with that fuzzy feeling


No kidding! Smile | :)

I had to test it too, AND I was just looking at it again (Thanks, LateNightsInNewry Poke tongue | ;-P ).

To start with, the test code in the first article I linked to (that demonstrates the new operator
throw) didn't work - well, not as I expected. That made me question all my assumptions in my
code.
Turns out, if you attempt to allocate a block too big for the platform, it breaks with a debug
message and returns NULL instead of an exception. Not a big deal, I guess - that should be caught
in the debug phase. But still, I was wondering if I had to check for NULL returns too.

Looking at the MFC source, MFC installs its own new handler and has a single static
CMemoryException object that it throws the address of.

I like your test code! Mine was more conservative (why I didn't use an infinite loop, I don't
know LOL)... borrowing from the article:
int * i_arr;
try {
   for (int i = 0; i < 1000000; i++)
      i_arr = new int[0x0fffffff];
} 
catch(...) {
   OutputDebugString("caught exception\n");
}

OMG | :OMG:

Cheers!
Mark




"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

GeneralRe: operator new and CObject Pin
Bram van Kampen19-Jun-07 14:27
Bram van Kampen19-Jun-07 14:27 
GeneralRe: operator new and CObject Pin
Mark Salsbery19-Jun-07 14:58
Mark Salsbery19-Jun-07 14:58 
QuestionQuery interface parameter Pin
_tasleem18-Jun-07 10:47
_tasleem18-Jun-07 10:47 
AnswerRe: Query interface parameter Pin
Mark Salsbery18-Jun-07 11:08
Mark Salsbery18-Jun-07 11:08 
GeneralRe: Query interface parameter Pin
_tasleem19-Jun-07 2:47
_tasleem19-Jun-07 2:47 
GeneralRe: Query interface parameter Pin
Mark Salsbery19-Jun-07 4:33
Mark Salsbery19-Jun-07 4:33 
GeneralRe: Query interface parameter Pin
_tasleem19-Jun-07 9:04
_tasleem19-Jun-07 9:04 
QuestionGDI+ documentation Pin
Force Code18-Jun-07 7:43
Force Code18-Jun-07 7:43 
AnswerRe: GDI+ documentation Pin
Mark Salsbery18-Jun-07 7:47
Mark Salsbery18-Jun-07 7:47 
GeneralRe: GDI+ documentation Pin
Force Code18-Jun-07 8:16
Force Code18-Jun-07 8:16 
GeneralRe: GDI+ documentation Pin
Mark Salsbery18-Jun-07 8:34
Mark Salsbery18-Jun-07 8:34 
GeneralRe: GDI+ documentation Pin
Force Code18-Jun-07 10:08
Force Code18-Jun-07 10:08 
GeneralRe: GDI+ documentation Pin
Mark Salsbery18-Jun-07 11:04
Mark Salsbery18-Jun-07 11:04 
QuestionHandling input and graphics in a game engine Pin
Cyrilix18-Jun-07 7:33
Cyrilix18-Jun-07 7:33 
AnswerRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 8:10
Force Code18-Jun-07 8:10 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 8:29
Cyrilix18-Jun-07 8:29 
GeneralRe: Handling input and graphics in a game engine [modified] Pin
Force Code18-Jun-07 8:51
Force Code18-Jun-07 8:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.