Garbage Collector : Ignoring a reference

Begah via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 26 06:35:37 PDT 2016


On Tuesday, 26 April 2016 at 13:01:26 UTC, ciechowoj wrote:
> On Tuesday, 26 April 2016 at 09:07:59 UTC, Begah wrote:
>> How could i tell the garbage collector to ignore the reference 
>> in the hashmap and to free it if there isn't any other 
>> reference that in my hashmap?
>
> You could always zero the reference in the hashmap, as it won't 
> be valid after reload anyway...

Nothing will reload.

An example :
I load a texture "button.png" in a class and draw it to the 
screen,
When the screen switches to another screen ie from menu to the 
game,
I want that the "button.png" texture is automaticly destroyed by 
the gc.
But this will never happen because i still have a reference to it 
in my hashmap.
Thus, i need a way to tell the gc to ignore the reference ( or 
something similar ) in that hashmap.


More information about the Digitalmars-d-learn mailing list