Allocation failures

cym13 via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 14 04:24:59 PST 2016


On Sunday, 14 February 2016 at 12:10:34 UTC, Jardík wrote:
> When I was interested in D some time ago, I believe GC was 
> aborting the application on allocation failures. Is that still 
> the case today? I am looking into using D for my new 
> application, but I need some guarantees that I can at least 
> save some critical data, when such thing happens, perhaps 
> freeing some stuff that is not really needed for the saving 
> part (e.g. I could destroy GUI, free all saved unmodified 
> documents and after that proceed to save unsaved changes to 
> temporary file of some kind (even unbuffered as i may not have 
> enough memory for a buffer). This is essential for me, that I 
> am able to do it, that there is a change to handle such 
> situation. The application will run on a system with 
> over-commit disabled, so that (C) malloc can correctly report 
> failures. Is it currently possible? Will it be possible in a 
> near future?
>
> [...]

Allocation failures throw errors such as onOutOfMemoryError which 
are meant to terminate the program (see the distinction between 
errors and exceptions in D) but I guess if you really need to you 
could catch it and save your data before exiting.


More information about the Digitalmars-d mailing list