So far, we have looked at creating Objects and using them in various simple ways but have not yet considered how to get rid of them again.
Every Object consumes various computer resources (principally memory)
and should be disposed of when it is no longer required, so as to free
up these resources. One way of doing this (not necessarily the
best--) is to annul each Object pointer once
you have finished with it, using astAnnul. For example:
zoommap = astAnnul( zoommap );
This indicates that you have finished with the pointer. Since astAnnul always returns the null value AST__NULL (as defined in ``ast.h''), the recommended way of using it, as here, is to assign the returned value to the pointer being annulled. This ensures that any attempt to use the pointer again will generate an error message.
In general, this process may not delete the Object, because there may
still be other pointers associated with it. However, each Object
maintains a count of the number of pointers associated with it and
will be deleted if you annul the final pointer. Using astAnnul
consistently will therefore ensure that all Objects are disposed of at
the correct time. You can determine how many pointers are associated
with an Object by examining its (read-only) RefCount attribute.
AST A Library for Handling World Coordinate Systems in Astronomy