Important: The information in this document is obsolete and should not be used for new development.
Disposing of a Palette and Restoring the Color Table
To prevent memory leaks, it is good programming practice to use theDisposePalette
function to dispose of palettes when your application is done with them. If you explicitly attach a palette to a window with theSetPalette
orNSetPalette
function, then your application owns the palette and must dispose of it when it is no longer needed. Note that a palette can be attached to more than one window, so closing a window doesn't necessarily mean that its palette is no longer needed.If you call
GetPalette
, which makes a copy of a window's palette, you must also callDisposePalette
when you no longer need the palette.If a palette has been set up automatically by the Palette Manager and Window Manager because the palette resource has the same ID as the window (or if the palette was created from the default application palette resource), then these managers automatically dispose of the palette when the window goes away.
It is also good programming practice to use the
RestoreDeviceClut
function to restore the color table of all graphics devices to their default state whenever your application is switched out as the active application. You don't have to worry about switching to the Finder, because its colors are automatically restored upon switching from applications that use the Palette Manager; nor do you need to be concerned with applications that use the Palette Manager, because the Palette Manager provides the proper colors the moment a window in such an application comes to the front. However, if you switch to an application that does not use the Palette Manager, its windows inherit your palette unless you have restored the default color tables for all the available display devices.