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 #61093 is a reply to message #60985] Sun, 17 November 2024 16:07 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14257
Registered: November 2005
Ultimate Member
This is a request that sound reasonable, but in practice is hard to implement, impossible to test and might have less impact than you think.

I mean, there are two reasons for out-of-memory situation:

- a bug. Some parameter in input data wrongly indicates that you have to alloc insane amount of memory and the allocation fails because it exceeds virtual memory. Your example falls into this category. So far I believe it is easier to account for that before the allocation (check the parameter) that trying to make the whole code out-of-memory resistant (e.g. check how String Stream::GetAll(int size) is implemented).

- a real memory exhaustion. That in hosts that we are interested means exhaustion of virtual memory space. In that case it is equally likely that the user part of host will crash too or that the computer will get virtually deadlocked trying to shuffle virtual memory or the process gets ultimately killed by OOM killer. Plus, to make things worse, it does not even has to happen in alloc! (Sometimes to really alloc the memory, you need to alloc it and then write to it...) So the effort you have invested in fixing all the code wents exactly nowehere.

(Fun fact: Last time I tried to demontrate futility of checking for out of memory with simple C code in Windows 10, I got blue screen as a result Smile

Mirek
 
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: Fri May 09 16:14:26 CEST 2025

Total time taken to generate the page: 0.02522 seconds