when is the object destuctor called?
Tom S
h3r3tic at remove.mat.uni.torun.pl
Mon May 22 09:45:52 PDT 2006
Derek Parnell wrote:
> On Tue, 23 May 2006 01:59:14 +1000, Jarrett Billingsley
> <kb3ctd2 at yahoo.com> wrote:
>> Then, I have a static dtor which loops through all the textures and
>> deletes them.
>
> I use the same technique. The idea that the only resource a ctor/dtor
> manages is RAM is plainly short-sighted.
IIRC, Walter's point was that objects that hold some important resources
should be manually memory-managed anyway. The GC is not guaranteed to
delete any objects, even these which aren't pointed to from a global
reference. This is because of the way the GC works. Maybe with a next GC
incarnation (e.g. a compacting one) *hint*, *hint*, we'll get stronger
guarantees ;)
As for the texture example, they should be freed by some sort of a
manager anyway - they have to be released before the rendering device
anyway...
Oh, and a question to Jarrett: why are you holding textures in an
associative array ? Just to be able to release textures in a O(log n)
time ? If so, how about a double - linked list, like the one Chris
presented recently on D.announce ? The AA seems weird :P
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d-pu s+: a-->----- C+++$>++++ UL P+ L+ E--- W++ N++ o? K? w++ !O
!M V? PS- PE- Y PGP t 5 X? R tv-- b DI- D+ G e>+++ h>++ !r !y
------END GEEK CODE BLOCK------
Tomasz Stachowiak /+ a.k.a. h3r3tic +/
More information about the Digitalmars-d
mailing list