Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Environment and Utilities /
Chapter 2 - QuickDraw GX Memory Management / Using Graphics Clients and Graphics Client Heaps


Disposing of a Graphics Client and Graphics Client Heap

When your application no longer needs a graphics client and its heap, you should dispose of them to free memory blocks. You can use the GXExitGraphics and GXDisposeGraphicsClient functions to do this.

While you are writing and debugging your application, it is a good idea to be meticulous about disposing of all graphics clients and graphics client heaps at the end of your application. As a result, you should use the GXExitGraphics function to dispose of the currently active graphics client heap and the GXDisposeGraphicsClient function to dispose of each active graphics client. If your application does not make these calls, QuickDraw GX automatically disposes of all graphics clients and heaps that belong to the exiting application. However, in this case, the graphics clients and heaps are considered aborted instead of being disposed of normally, and therefore QuickDraw GX does not report any errors that occur during the process of disposing of these graphics clients and heaps. Listing 2-3 shows how to properly dispose of a graphics client and its heap.

Listing 2-3 Disposing of graphics clients and graphics client heaps

.
. /* QuickDraw GX application code */
.
GXExitGraphics(void);
GXDisposeGraphicsClient(client);
}
Once your application is ready to ship, be sure to remove the terminating GXExitGraphics and GXDisposeGraphicsClient function calls and rely on QuickDraw GX to automatically dispose of all of your graphics clients and their heaps for your exiting application. When your application quits, it is much faster for QuickDraw GX to throw away all of the graphics clients and their graphics client heaps, rather than to dispose of each of them sequentially. This approach is analogous to quitting an application rather than taking the extra time to close multiple application windows.

The GXExitGraphics function is described on page 2-23. The GXDisposeGraphics function is described on page 2-21.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996