The preceding sample program provides a way of exiting gracefully with the cleanup() subroutine. This function returns to the memory manager all dynamically-allocated memory chunks. Notice the calls to freeraster() and freecolormap(). these calls correspond directly to the allocation calls allocraster() and getcolormap() located in the body of the program. now look at the calls within cleanup() to freevportcoplists() and freecprlist(). when you call makevport(), the graphics system dynamically allocates some space to hold intermediate instructions from which a final Copper instruction list is created. When you call mrgcop(), these intermediate Copper lists are merged together into the final Copper list, which is then given to the hardware for interpretation. It is this list that provides the stable display on the screen, split into separate viewports with their own colors and resolutions and so on. When your program completes, you must see that it returns all of the memory resources that it used so that those memory areas are again available to the system for reassignment to other tasks. Therefore, if you use the routines makevport() or mrgcop(), you must also arrange to use freecprlist() (pointing to each of those lists in the view structure) and freevportcoplists() (pointing to the viewport that is about to be deallocated). If your View is interlaced, you will also have to call FreeCprList(&view.SHFCprList) because an interlaced view has a separate Copper list for each of the two fields displayed. Do not confuse FreeVPortCopLists() with FreeCprList(). The former works on intermediate Copper lists for a specific ViewPort, the latter directly on a hardware Copper list from the View. As a final caveat, notice that when you do free everything, the memory manager or other programs may immediately change the contents of the freed memory. Therefore, if the Copper is still executing an instruction stream (as a result of a previous loadview()) when you free that memory, the display will malfunction. Once another view has been installed via LoadView(), do a waittof() for the new view to begin displaying, and then you can begin freeing up your resources. WaitTOF() waits for the vertical blanking period to begin and all vertical blank interrupts to complete before returning to the caller. The routine waitbovp() (for "WaitBottomOfViewPort") busy waits until the vertical beam reaches the bottom of the specified viewport before returning to the caller. this means no other tasks run until this function returns.