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 handle a lack of memory
Re: How to handle a lack of memory [message #46281 is a reply to message #46272] Thu, 07 April 2016 22:59 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13976
Registered: November 2005
Ultimate Member
It is not so easy...

Frankly, it all boils down to VectorMap::Add implementation as example:


T& Add(const K& k, const T& x) { key.Add(k); return value.Add(x); }

Now if value.Add runs out of memory, VectorMap is left in inconsistent state. Not that this is just example, practical code is full of examples like this. E.g. what is wrong with this code:

struct Foo {
   Bar *ptr;

   Foo() { ptr = new Bar; }
   ~Foo() { delete ptr; }
}


It is certainly possible to solve that by adding exception block into Add, but correctly resolving this issue everywhere would result in significant increase in codebase (and probably decreased performace). And it is virtually untestable.

Plus, in 64 bit platform (but often with 32-bits too), you are rather going to freeze system first (because of swap trashing) that actually get to out-of-memory.

In practice, I do not remember getting out-of-memory in other situations that program bugs. Have you ever got out-of-mem in theide?

Mirek

[Updated on: Thu, 07 April 2016 23:00]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Please help! New transfer semantic issue!
Next Topic: [FIXED] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
Goto Forum:
  


Current Time: Sun May 12 09:09:42 CEST 2024

Total time taken to generate the page: 0.02827 seconds