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   |
 |
mirek
Messages: 14257 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
|
|
|
|
|
Re: How to handle a lack of memory [message #46298 is a reply to message #46288] |
Mon, 11 April 2016 08:33   |
 |
koldo
Messages: 3435 Registered: August 2008
|
Senior Veteran |
|
|
Hello Mirek
I agree with you. However I think that this issue should have to be solved some time.
Maybe it is not possible to solve it soon for all cases, but maybe it is possible to solve it for a big percentage of them.
Remember the Pareto principle (for example, with 20% of the effort you may solve the 80% of the problem) .
Best regards
Iñaki
[Updated on: Mon, 11 April 2016 08:35] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sun May 11 12:05:43 CEST 2025
Total time taken to generate the page: 0.00764 seconds
|