Jump to content

  • Log In with Google      Sign In   
  • Create Account


collinstocks

Member Since 31 May 2013
Offline Last Active Jun 05 2013 12:22 PM
-----

Posts I've Made

In Topic: Object handle getting released; causing a null pointer error?

31 May 2013 - 11:21 PM

Sorry for coming into this late, but could this possibly be resolved (in this particular case, and maybe in others) by having the gc preferentially releasing handles that are members of objects with no destructors?

 

That is, in this case the gc would first release the Character::avatar handle. At this point, the Avatar would have no more references, and could be destructed safely.

 

Of course, this solution doesn't quite work if you have circular references between classes that each have destructors, but then that is the programmer's own fault, right? happy.png

 

This method of breaking circular references is used by Python and the Boehm GC, although the way each of these handle the case of circular references among objects that all have destructors is to never collect the objects . . . I think that your solution is better in this case. Or, perhaps, throw an exception and refuse to run the destructors. That sounds more complicated, though.


PARTNERS