Solved

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

Posted on 2012-04-04
1
246 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

757 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

19 Experts available now in Live!

Get 1:1 Help Now