[futurebasic] Re: purging resources

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 1998 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Mon, 16 Mar 1998 20:14:07 -0600
David wrote:
> Here is why you should never have the need to call ReleaseResource - and 
> why it is better for everyone if you don't do it:
(snip)

This is good advice, but there are also a couple of other things to
consider:

* If you are really, truly done with the resource, then you might as
well call ReleaseResource.  There's housecleaning done when a resource
is released, that _isn't_ done when it's purged.  Specifically, when a
resource is purged the Memory Manager won't release the block's master
pointer (because the thought is that you may wish to read a purged
resource back into memory using the same handle).  Purgeability wasn't
designed as a means of automatic "garbage collection"--it was designed
as a way to let things be (temporarily) swapped out of memory when
memory is scarce.

* You need take additional care when working with a purgeable
resource--namely, when you want to directly access or alter the data,
you need to make sure the resource hasn't already been purged!  Calling
HNOPURGE won't do much good if the resource is already gone from
memory.  You should also always call LOADRESOURCE if you think there's
any chance the resource might have been purged since the time you first
got its handle.

- Rick