Click here to Skip to main content
15,895,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 12:02
Cyrilix24-Sep-08 12:02 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 12:08
Mark Salsbery24-Sep-08 12:08 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 14:10
Cyrilix24-Sep-08 14:10 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 15:05
Mark Salsbery24-Sep-08 15:05 
Questionerror LNK2019 Pin
susanne124-Sep-08 5:12
susanne124-Sep-08 5:12 
QuestionRe: error LNK2019 Pin
CPallini24-Sep-08 5:25
mveCPallini24-Sep-08 5:25 
AnswerRe: error LNK2019 Pin
Hamid_RT24-Sep-08 6:11
Hamid_RT24-Sep-08 6:11 
Questioninvalid memory allocation not throwing exception but opening Windows message box? Pin
T.T.H.24-Sep-08 5:11
T.T.H.24-Sep-08 5:11 
I do have a wicked anomaly regarding an "out of memory" situation which behaves differently in two of my applications.

Application 1, let it be called "tool", is an inhouse tool, MFC based with full MFC GUI and stuff.

Application 2, let it be called "client", is a multiplayer game client, using MFC but only for the network socket, the whole GUI being custom on top of OpenGL/DirectX.

Both applications are made with Visual C++ 2003.NET / v7.1.6030 unter WindowsXP. Only the "Release" mode is currently used.

For exception handling of win32 exceptions both have the following project properties set...
Project Properties -> C/C++ -> Code Generation -> Enable C++ Exceptions = No
Project Properties -> C/C++ -> Command Line = /EHa

...plus...
_set_se_translator(myfunction)

...is used (based on the information I found here[^]).

But the wicked thing comes with memory allocation and the throwing vs. not-throwing of a std::bad_alloc exception. If I put the following code into both applications...
Byte* pData = NULL;
try {
  int Amount = 0;
  --Amount;
  pData = new Byte[Amount];
}
catch (std::bad_alloc& E) {
  // my own error handling
}

...they behave differently:

The "tool" behaves as I would expect and a std::bad_alloc exception is thrown, catched and my own error handling does the rest.

But in the "client" a Windows message box comes up, simply telling me "Out of memory." with a black exclamation mark in a yellow triangle plus an OK button and if I press the OK button the application continues to run - which actually gives me a big "WTF?" moment. One way or the other that behaviour is neither intended nor appreciated.

My best guess is that it depends on the compiler settings but I wasn't able yet to find any meaningful differences. I already experimented with optimization levels but couldn't change the application's behaviour doing so. Could anybody give me a hint on what the problem might be?

Thanks,
T.T.H.
AnswerRe: invalid memory allocation not throwing exception but opening Windows message box? Pin
T.T.H.30-Sep-08 4:12
T.T.H.30-Sep-08 4:12 
QuestionSend a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 4:46
Joseph Marzbani24-Sep-08 4:46 
AnswerRe: Send a file to an eMail address "silently" Pin
Iain Clarke, Warrior Programmer24-Sep-08 4:56
Iain Clarke, Warrior Programmer24-Sep-08 4:56 
GeneralRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 5:03
Joseph Marzbani24-Sep-08 5:03 
GeneralRe: Send a file to an eMail address "silently" Pin
Perspx24-Sep-08 6:14
Perspx24-Sep-08 6:14 
AnswerRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 7:06
Joseph Marzbani24-Sep-08 7:06 
GeneralRe: Send a file to an eMail address "silently" Pin
Perspx24-Sep-08 7:10
Perspx24-Sep-08 7:10 
GeneralRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 7:37
Joseph Marzbani24-Sep-08 7:37 
GeneralRe: Send a file to an eMail address "silently" Pin
CPallini24-Sep-08 7:21
mveCPallini24-Sep-08 7:21 
GeneralRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 7:40
Joseph Marzbani24-Sep-08 7:40 
QuestionIOCP Socket Timeout Problem.. Pin
onlyjaypatel24-Sep-08 4:29
onlyjaypatel24-Sep-08 4:29 
QuestionRe: IOCP Socket Timeout Problem.. Pin
Mark Salsbery24-Sep-08 6:33
Mark Salsbery24-Sep-08 6:33 
AnswerRe: IOCP Socket Timeout Problem.. Pin
cmk25-Sep-08 10:37
cmk25-Sep-08 10:37 
QuestionMAPI problem! Pin
josip cagalj24-Sep-08 4:18
josip cagalj24-Sep-08 4:18 
AnswerRe: MAPI problem! Pin
josip cagalj25-Sep-08 1:45
josip cagalj25-Sep-08 1:45 
QuestionHow to implement such a cache scheme in C++? [modified] Pin
followait24-Sep-08 3:56
followait24-Sep-08 3:56 
QuestionHow can connect MySQL database with VC++ mfc application Pin
param_joshi24-Sep-08 2:06
param_joshi24-Sep-08 2:06 

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.