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


Determining Memory Requirements for a Graphics Client Heap

Using the optimal heap size increases the performance of your application. If your application does not allocate sufficient memory, QuickDraw GX will need to add additional memory blocks to the initial graphics client heap. If your heap is sized too large, you are wasting memory space.

You can use the QuickDraw GX GraphicsBug utility to check the actual size of your graphics client heap to ensure that your application has allocated sufficient, but not excessive, memory. Once you determine the optimal graphics client heap size for your application, you can specify this size at the beginning of your application by using the GXNewGraphicsClient function.

You can use the following procedure to determine the memory requirements of your graphics client heap:

  1. Start your application with the GXNewGraphicsClient function and specify a memory size, such as 1 MB.
  2. Run your application and create a document. QuickDraw GX allocates or deallocates memory blocks to a size that it deems necessary and sufficient to accommodate the number and complexity of the objects you have created.
  3. Use the Heap Total (HT) GraphicsBug command to determine the memory size that QuickDraw GX is currently using. This is the size of the graphics client heap.
  4. Use the GXNewGraphicsClient function to specify the size of the QuickDraw GX graphics client heap to accommodate the actual memory required.

Repeat these steps varying the size of the document used in step 2.

By running your application with what you would consider to be a document of average size and then with a document of large size, you can arrive at an optimum graphics client heap size that is probably somewhere between these two heap sizes. One important consideration is to ensure that your largest objects have sufficient memory allocated for the graphics client heap that they reside in. This is because an object cannot be split into multiple memory blocks in the heap.

Because QuickDraw GX can grow the heap to accommodate the needs of your application, you don't need to allocate sufficient space for your largest document. Assuming you have not passed the gxStaticHeapClient attribute to GXNewGraphicsClient. This procedure provides only a preliminary evaluation of the memory requirements for your application.

For additional information on how to use the GraphicsBug utility, see the section "Debugging With GraphicsBug" in the chapter "QuickDraw GX Debugging," in this book.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996