if d-tor is called, does it means the object is gc-ed?

Lionello Lunesu lionello at lunesu.remove.com
Thu Oct 5 22:36:30 PDT 2006


"%u" <no at where.com> wrote in message news:eg3lg4$123$1 at digitaldaemon.com...
> Sorry for the stupid question, but I'm puzzled.
>
> I have some code like this:
>
> class A {
>
> ~this() {
>  printf("d-tor\n");
> }
>
> }
>
> And I created lots of A's.  At some point in my program I explicitly did:
> delete a;  for all the a's.
>
> And the printed msg shows the d-tor is called.  But From the system 
> monitor, I
> didn't see the memory usage is decreased.  So I wonder whether the memory 
> is
> actually freed.

You shouldn't worry about the memory usage shown in system monitor. The 
memory usage in the windows task manager, for example, is reserved Virtual 
Memory. This doesn't actually mean anything, since an app can reserve 
virtual memory as much as it wants, without consuming even a bit of physical 
memory.

Like Sean said, your objects will have been freed by the GC, but the virtual 
memory won't be freed, and why should it be freed: it doesn't actually cost 
anything.

L. 





More information about the Digitalmars-d-learn mailing list