ADC Home > Reference Library > Technical Notes > Legacy Documents > Mac OS 9 & Earlier >
Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.
Current information on this Reference Library topic can be found here:
Defining the Problem
Like other definition functions, WDEFs contain executable code that needs to be locked down in memory whenever it is executed. If your application is using a custom WDEF marked as purgeable, the Memory Manager may purge the WDEF resource in order to allocate additional memory in your application heap. The Window Manager will reload the WDEF resource if necessary before calling it. If your application is the "current" application, i.e. the one that is executing but may not necessarily be frontmost, the Window Manager can reload the WDEF resource. Everything works fine.
The Problem Scenario
The following is a sequence of events that may cause the problem to occur: The Window Manager calls your WDEF when it needs to redraw your windows even if your application is not current. It does this by calling your WDEF directly whenever your windows get erased. If the WDEF has been purged, the Window Manager will try to reload the WDEF. Since your application is not the "current" application, your application's context has not been restored and your resource chain is not the current resource chain. As a consequence, the Window Manager attempts to load a WDEF from the wrong resource chain. Since it can't find the WDEF, it calls SysError(87).
Why This Hasn't Been a Problem Before
There are three reasons why this hasn't been a problem in the past.
The Simple Fix
The simple fix to the problem of your WDEFs not being able to be reloaded is to mark your WDEFs as non-purgeable. This prevents the Memory Manager from purging the WDEF, so it is always available even if your application is not frontmost.
Additional Notes & Comments
The following are some important items that you may need to consider when working through the problem of purgeable WDEFs:
The problem with purgeable WDEFs can be fixed by simply marking their resources as non-purgeable.