Solved

How can you tell when a multimap insertion fails due to Out Of Memory

Posted on 2012-04-04
1
258 Views
Last Modified: 2012-04-07
Quite simply, how can you tell when a multimap insertion fails due to running out of memory?  I expected that this would be easily found on Google but have had no luck.  My two guesses would be that it would return end() or that it would throw an exception but I haven't managed to find anything definitive.
0
Comment
Question by:iyac
1 Comment
 
LVL 22

Accepted Solution

by:
ambience earned 50 total points
ID: 37806513
Nope it will definitely not return end() because of an out of memory condition. I'm saying this because thats not a general design strategy in STL. The world is divided wrt whether new operator would throw std::bad_alloc when it fails to allocate memory or not. STL variant that favor exceptions - possibly this behavior is configurable - you can expect a std::bad_alloc exception. For others, I'm not sure - but i think it will just crash.

For example, VisualStudio has the define

#define _HAS_EXCEPTIONS 1

If you set this to 0 it will not throw std::bad_alloc.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

733 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