Solved

Displaying a dialog after CResourceException

Posted on 2001-06-22
2
707 Views
Last Modified: 2013-11-20
When my app receives a CResourceException or CMemoryException, I'd like to display a dialog telling my user that that's the reason I'm about to exit on him.

I plan to pre-allocate the dialog, and I'm catching the exception fine (in my override of CWinApp::ProcessWndProcException()).  But can I assure that my dialog will show when I call DoModal()?  It seems that will try to use a few more resources above and beyond what was preallocated.  Can I free up some pre-allocated memory for use just by my app or my pre-allocated dialog?

I realize this solution may just be for the CMemoryException and not the CResourceException, but that's alright.

thanks for any pointers or code,
bruce
0
Comment
Question by:bwdean
2 Comments
 
LVL 2

Accepted Solution

by:
Slordak earned 100 total points
ID: 6235435
I would suspect that it depends on how the heap is being managed (and whether one is using the debug or release heaps, for example).

The first thing to determine would be how much heap memory is being used to create your modal dialog, and if there are any other resources (handles, tokens, semaphores, etc.) that might potentially be exhausted as well.  Assuming the only thing your dialog needs is additional heap memory, one possibility would be to allocate this much memory via a malloc/new call at the beginning of your program, then release this memory just prior to creating your dialog, assuming the heap is going to let you immediately re-use the memory and is not saving it for later garbage collection or for memory auditing purposes.  This is probably not ideal, but its hard to anticipate every possible error conditio, after all.

You'd probably also want to muck with some of the dialog settings.  I.e. Make your critical error dialog resource non-discardable while the other dialogs can be marked discardable, thereby attempting to guarantee that the dialog you need will be available in low-resource conditions.
0
 

Author Comment

by:bwdean
ID: 6410225
And two months later, I get around to responding....Thanks for the input..already what I was basically doing, but the dialog settings suggestions are good info.

thanks!
bruce
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now