Important: The information in this document is obsolete and should not be used for new development.
SetResPurge
You can use theSetResPurgeprocedure to have the Memory Manager pass the handle of a resource to the Resource Manager before purging the data specified by that handle.
PROCEDURE SetResPurge (install: Boolean);
install- A Boolean value that specifies whether the Memory Manager checks with the Resource Manager before purging a resource handle.
DESCRIPTION
SpecifyTRUEin theinstallparameter to make the Memory Manager pass the handle for a resource to the Resource Manager before purging the resource data to which the handle points. The Resource Manager determines whether the handle points to a resource in the application heap. It also checks if the resource'sresChangedattribute is set to 1. If these two conditions are met, the Resource Manager calls theWriteResourceprocedure to write the resource's resource data to the resource fork before returning control to the Memory Manager.Specify
FALSEin theinstallparameter to restore the normal state, so that the Memory Manager purges resource data when it needs to without calling the Resource Manager.You can use
SetResPurgein applications that modify purgeable resources. You should also take precautions in such applications to ensure that the resource won't be purged while you're changing it.SPECIAL CONSIDERATIONS
If you callSetResPurgewith theinstallparameter set toTRUEand then call the Memory Manager procedureMoveHHito move a handle to a resource, the Resource Manager calls theWriteResourceprocedure to write the resource data to disk even if the data has not been changed. To prevent this, callSetResPurgewith theinstallparameter set toFALSEbefore you callMoveHHi, then callSetResPurgewith theinstallparameter set toTRUEimmediately after you callMoveHHi.Whenever you call
SetResPurgewith theinstallparameter set toTRUE, the Resource Manager installs its own purge-warning procedure, overriding any purge-warrning procedure you've specified to the Memory Manager.SEE ALSO
To check for errors, call theResErrorfunction as described on page 1-47.For descriptions of the
SetResAttrsandWriteResourceprocedures, see page 1-80 and page 1-88, respectively.For more information about the Memory Manager procedure
MoveHHi, see Inside Macintosh: Memory.