Bug 2757 – resource management in a timely manner

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2009-03-24T03:49:00Z
Last change time
2014-11-13T10:34:47Z
Keywords
spec
Assigned to
bugzilla
Creator
nick.barbalich

Comments

Comment #0 by nick.barbalich — 2009-03-24T03:49:34Z
email 23 Mar 2009 from the D.d list. Subject : "Re: new D2.0 + C++ language". Sat, 21 Mar 2009 20:16:07 -0600, Rainer Deyke wrote: > > Sergey Gromov wrote: >> >> I think this is an overstatement. It's only abstract write buffers >> >> where GC really doesn't work, like std.stream.BufferedFile. In any >> >> other resource management case I can think of GC works fine. > > > > OpenGL objects (textures/shader programs/display lists). > > SDL surfaces. > > Hardware sound buffers. > > Mutex locks. > > File handles. > > Any object with a non-trivial destructor. > > Any object that contains or manages one of the above. > > > > Many of the above need to be released in a timely manner. For example, > > it is a serious error to free a SDL surface after closing the SDL video > > subsystem, and closing the SDL video subsystem is the only way to close > > the application window under SDL. Non-deterministic garbage collection > > cannot work. > > > > Others don't strictly need to be released immediately after use, but > > should still be released as soon as reasonably possible to prevent > > resource hogging. The GC triggers when the program is low on system > > memory, not when the program is low on texture memory. > > > > By my estimate, in my current project (rewritten in C++ after abandoning > > D due to its poor resource management), about half of the classes manage > > resources (directly or indirectly) that need to be released in a timely > > manner. The other 50% does not need RAII, but also wouldn't benefit > > from GC in any area other than performance. Thanks for the explanation, it really helps to keep this picture in mind.
Comment #1 by bugzilla — 2009-03-27T03:38:37Z
What is the enhancement request?
Comment #2 by dfj1esp02 — 2009-04-02T07:50:18Z
This guy wants gc to free "unmanaged" resources each 10 seconds, because if gc objects, wrapping those resources, don't occupy much space, gc won't bother to collect garbage.
Comment #3 by nick.barbalich — 2009-05-04T06:14:40Z
Why was this set to Status: Resolved & Resolution:Invalid ?
Comment #4 by dfj1esp02 — 2009-05-05T06:09:12Z
Because your solution doesn't solve even your problem.
Comment #5 by nick.barbalich — 2009-05-07T03:11:56Z
(In reply to comment #5) > Because your solution doesn't solve even your problem. Perhaps you would like to propose a better solution ? My original request was have some mechanism (not defined) to release resources as soon as reasonably possible to prevent resource hogging. Perhaps if a object (e.g. buffer, lock, or handle etc) is defined, as a member of a resource pool, then a resource process will wake-up every x.xx seconds (as configured by the programmer) and remove any freed objects. The programmer should be able to define multiple resource pools. It would be desirable if the resource process could report how many resources had been freed, every wake-up, or a defined period of time.
Comment #6 by dfj1esp02 — 2009-05-07T06:28:35Z
Comment #7 by bartosz — 2009-08-23T14:44:31Z
The problem of deterministic destruction can be solved by reference counting or uniqueness. Both may be implemented in the library. D2 will have full support for RAII using structs with the "postblit" operator, this(this). I am currently implementing a reference-counted thread handle and, as soon as compiler bugs are ironed out, I'll templatize it and put in the standard library.
Comment #8 by nick.barbalich — 2009-08-25T03:57:45Z
(In reply to comment #7) > The problem of deterministic destruction can be solved by reference counting or > uniqueness. Both may be implemented in the library. D2 will have full support > for RAII using structs with the "postblit" operator, this(this). I am currently > implementing a reference-counted thread handle and, as soon as compiler bugs > are ironed out, I'll templatize it and put in the standard library. Bartosz - Thanks for the reply. I found this reference to "postblit": http://www.puremagic.com/~braddr/phobos-trunk/2.0/struct.html#StructPostblit But I use the Tango library. Will an example be available in Tango, or will there be an equivalent available for Tango ?
Comment #9 by bugzilla — 2014-11-13T10:34:47Z
Won't implement, because this is the job of reference counting.