GC for noobs

Xavier Bigand flamaros.xavier at gmail.com
Fri Feb 28 12:01:57 PST 2014


Le 28/02/2014 13:22, Szymon Gatner a écrit :
> On Friday, 28 February 2014 at 11:43:58 UTC, Dicebot wrote:
>> On Friday, 28 February 2014 at 11:28:01 UTC, Szymon Gatner wrote:
>>> I didn't mean "basic" in the sense of "easy" but in the sense of
>>> something that has to dealt with all the time / is common requirement.
>>
>> Yes, it needs to be dealt with all the time but in a different ways.
>> Problem is with getting sensible defaults. D makes a reasonable
>> assumption that most applications don't actually care about tight
>> bullet-proof resource management and defaults to GC. I may not like it
>> but it fits criteria "built-in resource management" and pretty much
>> shows that it is not as basic as one may think.
>>
>
> Not really different tho. Actual function call swqence might be
> different but the scheme is always the same: acquire resource, allocate,
> connect, take from pool vs release, deallocate, disconnect, return to
> pool. All of those fall under resource management - there is a finite
> amout of a resouce whether it is a memory, a system process, a file or a
> databese connection and it is crucial to the system stability that all
> of them are properly returned / released AND in proper order (which is
> of course reverse to "acquisition").

I had a lot of difficulties too with the release order of resources. Of 
course I am coming from c++, in which it's to ease to manage.
I got some head-hack for the resource management, maybe a DIP must be 
done here about a module dedicated to the resource management? Or at 
least a tutorial in the wiki?


I finally solve my issues, but I am not happy, cause the way it's done 
seems to be too much error prone (resource leaks).


I used to work on mobile devices and some kind of resources have to be 
released as soon as possible. I also don't really like having a lot of 
applications running on devices never releasing resources, it can break 
the principle of multi-task OS. Just try to launch many Java/C# 
applications at the same time, you'll have to buy more memory.


More information about the Digitalmars-d-learn mailing list