Important: The information in this document is obsolete and should not be used for new development.
Loading and Unloading Objects
If your application needs more memory during execution, QuickDraw GX automatically unloads objects to disk storage to free memory. QuickDraw GX automatically reloads previously unloaded objects when it needs them.QuickDraw GX only begins to unload objects after it has failed to free sufficient memory by disposing of dead caches, unloading picture shape objects, disposing of live caches, relocating bit images, and adding additional memory blocks to the graphics client heap. Unless you choose to control loading and unloading of objects to memory, QuickDraw GX performs these tasks for you automatically. Your application never needs to load or unload an object.
The order in which QuickDraw GX automatically loads and unloads objects depends upon the objects' shape attributes. QuickDraw GX first unloads shape objects with the
gxDiskShape
attribute. QuickDraw GX then unloads shapes without special attributes, style, ink, transform, color set, color profile, and tag objects. Finally, after all other objects are unloaded, QuickDraw GX unloads objects with thegxMemoryShape
attribute.You can use the
GXSetShapeAttribute
function to set or clear an object's shape attribute and theGXGetShapeAttribute
function to determine which attributes of a shape object are set. Shape attributes are described in the chapter "Shape Objects" in Inside Macintosh: QuickDraw GX Objects.Objects are unloaded to a temporary file created on the startup disk in the invisible temporary items folder. When an object is unloaded, a 4-byte stub remains in memory to describe the location of each object on disk so that it can be reloaded when required. Sufficient disk storage space must be available to accommodate all of the objects that are unloaded or a file system error is posted.
You can supplement QuickDraw GX automatic loading and unloading operations by using function calls. These functions may be useful in increasing application performance. For example, a multimedia application with time-critical processing may need to control specific objects to ensure that they are resident in memory when they are to be displayed and removed from memory when they are no longer required.
You can use the
GXUnloadShape
function to move a shape from memory to disk storage and theGXLoadShape
function to move a shape from disk storage to memory. QuickDraw GX provides loading and unloading functions for shape, style, ink, transform, color set, color profile, and tag objects.When you unload an object, QuickDraw GX always first disposes of all of the live and dead caches for the object.
A recommended approach is to initially write your application without the use of object loading and unloading functions. Then, experiment with loading and unloading functions to improve performance.
The QuickDraw GX loading and unloading functions are described in the section "Loading and Unloading Objects" beginning on page 2-26.
When objects are loaded and unloaded by QuickDraw GX is discussed in the section "Low-Memory Conditions" beginning on page 2-10.