Note that deletion is unconditional, regardless of whether other pointers to the Object are still in use (possibly within other Objects). A safer approach is to defer deletion, until all references to an Object have expired, by using astBegin/astEnd (together with astClone and astAnnul if necessary).
AST A Library for Handling World Coordinate Systems in Astronomy