Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to respond when memory is exceeded
Re: How to respond when memory is exceeded [message #61119 is a reply to message #61112] Tue, 19 November 2024 12:14 Go to previous message
mirek is currently offline  mirek
Messages: 14265
Registered: November 2005
Ultimate Member
So it is now implemented in "bad_alloc" branch. Basically, memory panic now throws bad_alloc which then caught in APP_MAIN to do normal Panic, so you can try and catch it.

Note that U++ code reaction to bad_alloc right now is

a) uncertain
b) likely and the ideal I will be striving upon, it is only safe to completely destruct U++ structures created in bad_alloc try block, there is no guarantee that any other operation works. Example:

VectorMap<String, String> map;
try {
   map.Add("Hi", "there");
}
catch(std::bad_alloc) {}


is bad code. Instead you can use

VectorMap<String, String> map;
try {
   VectorMap<String, String> map2;
   map2.Add("Hi", "there");
   map = pick(map);
}
catch(std::bad_alloc) {}


[Updated on: Tue, 19 November 2024 12:22]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: NoMemoryLeaksCheck undefined symbol
Next Topic: Doubt with Buffer<> of a trivially destructible type
Goto Forum:
  


Current Time: Mon Jul 07 09:35:32 CEST 2025

Total time taken to generate the page: 0.03927 seconds