Article # 210, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
Recreating a lazarus condition
The Lazarus effect occurs when an app is exited, and restarted again before it was fully exited. Generally what will happen is global variables will already be initialized and memory blocks and UI elements will already exist. This can lead to memory leaks and UI problems if you aren't testing for this condition. Handling these problems is generally as simple as checking for the existing UI objects or memory blocks, as well as initializing global variables in your MSG_GEN_PROCESS_OPEN_APPLICATION method. Here's how to test for the lazarus condition: - start the app - break in swat - type "exit {appname}" As soon as the home screen is visible and before the app fully exits, hit its icon to start it up again. This causes a lazarus condition: the app goes all the way down to engine mode, then realizes it needs to restart and runs MSG_GEN_PROCESS_OPEN_APPLICATION without the usual cleanup code getting executed (in MSG_GEN_PROCESS_CLOSE_APPLICATION, for example). This can cause problems if the app expects dgroup data to be initialized a certain way or if items are dynamically allocated and manipulated on startup without checking if they have already been created. Eventually, dgroup will be automatically reinitialized in this case, but not as things stand, so watch out. There are a number of ways you can tell if your app is restarting without fully detaching: the AppAttachFlags passed in MSG_GEN_PROCESS_OPEN_APPLICATION mention it. Or you can add some vardata element to an object on startup and check for its existence before doing one-time-only code.