Panics and the CleanupStack

Login to reply to this topic.
Tue, 2005-03-01 13:27
Joined: 2005-03-01
Forum posts: 6
Hi all

Im wondering what happens to memory allocated on the heap after a panic has occured. If a panic might occur, should we then add allocated objects to the cleanup stack before attempting to do the thing that could panic the app. Will the os attempt to destoy items on the cleanupstack after a panic?  


Thanks Smiley

Tue, 2005-03-01 13:33
Joined: 2005-02-16
Forum posts: 22
Panics and the CleanupStack
The CleanupStack is for recovering from a Leave.

Contrary to 99% of 3rd party software, error conditions that Leave can actually be dealt with and mitigated - it is termed "graceful degradation".  If you have an untrapped leave, ultimately that becomes a panic.

A panic does completely clear the resources (e.g. memory) of the panicked app.  So don't worry about it!

(Unless you override the default panic handler, and then all bets are off.)
Tue, 2005-03-01 13:50
Joined: 2005-03-01
Forum posts: 6
Great :-)
Thanks for the quick and clear answer, Elk!

Im aware that the cleanup stack is a mechanism to clean up after a leave - I jst speculated about whether to worry about 3rd party external code that might panic  unexpectedly and thereby orpahane memory i've allocated .  But that doesnt seem to be something to worry about.

Smiley
  • Login to reply to this topic.