next up previous 264
Next: AST Pointer Contexts Begin and End
Up: An AST Object Primer
Previous: Transforming Coordinates


Managing Object Pointers

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.


next up previous 264
Next: AST Pointer Contexts Begin and End
Up: An AST Object Primer
Previous: Transforming Coordinates

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
25th February 2013
E-mail:starlink@jiscmail.ac.uk

Copyright (C) 2014 Science \& Technology Facilities Council