Resource management summary Most Common Graphics resources need to be explicitly deallocated when no longer required, otherwise operating system resources are lost and will eventually run out. This includes fonts, pixmaps, color cells, graphics contexts, cursors, and icons. Often the best place to deallocate graphics resources is in a destroy callback handler for the drawing area widget in which graphics are being drawn. See "Drawing area widgets" for more information. The following table summarizes when and how to free graphics objects allocated by the application: Table 27. Graphics object freeing reference Graphics object Summary CgCursor Obtained using: CgDisplay>>createFontCursorCgPixmap>>createPixmapCursorCgFont>>createGlyphCursor Freed using: CgCursor>>freeCursor When to free: When it will no longer be set as the cursor for any window (using CgWindow>>setWindowCursor:). Cursors are normally allocated when an application is opened and freed when it is closed. CgDeviceIndepen- dentImage Obtained using: CgDeviceIndependentImage class>> width:height:depth:palette: width:height:depth:palette:scanlinePad:data: Freed using: <None> When to free: Images do not need to be explicitly freed. CgDirectPalette Obtained using: CgDirectPalette class>> redMask:greenMask:blueMask: Freed using: <None> When to free: Direct palettes do not need to be explicitly freed. CgGC Obtained using: CgWindow>>createGC: Freed using: CgGC>>freeGC When to free: When it is no longer required for graphics operations on the drawable for which it was created. It is typically freed when a window is closed by hooking the destroy callback. CgFont Obtained using: CgDisplay>>loadFont: Freed using: CgFont>>unloadFont When to free: When it is no longer required for graphics operations on any drawable. It is typically freed when no more text will be drawn with that font. The font can remain selected in a CgGC but if a request using the font is made, such as drawing a string, the results are undefined. CgFontStruct Obtained using: CgDisplay>>loadQueryFont:CgFont>>queryFont Freed using: CgFontStruct>>freeFont When to free: When it is no longer required for information about its font and when no more text will be drawn with that font. The same conditions as for freeing CgFont apply. CgIndexedPalette Obtained using: CgIndexedPalette class>>entries:colors: Freed using: <None> When to free: Indexed palettes do not need to be explicitly freed. CgIcon Obtained using: CgIcon class>>fromImage:maskImage:fromOSIcon:fromResource:fromResource:fileName:fromResources:fromResources:fileName:fromSystem:width:height:depth:palette:shapePad:- shapeData:maskPad:maskData: Freed using: CgIcon>>freeIcon When to free: When it will no longer be drawn and it is no longer set as an icon resource of a widget. CgPixmap Obtained using: CgDrawable>>createPixmap:createBitmapFromData:createPixmapFromBitmapData:readBitmapFile: Freed using: CgPixmap>>freePixmap When to free: When it will no longer be used for drawing on, it will no longer be used as the source for a copy operation, and it will no longer be used as a tile or stipple pattern in a GC. CgArc, CgCharStruct, CgFontProp, CgGCValues, CgRGBColor, CgSegment, CgTextItem Obtained using: <Misc> Freed using: <None> When to free: These objects are informational data structures only, and need not be explicitly freed.