Copy link to clipboard
Copied
Hi all,
I'm new to the SDK and i've been playing around with it;
I'm allocating memory for a displacement map, an array of pixels, and I want to free that memory when my effect is either deactivated or deleted. How do I listen for that deactivation / deletion? Any help is much appreciated.
Copy link to clipboard
Copied
Hi no258
Usually you will allocate and free the memory per frame rendered. If you are caching resources, you can store them in global data and clean them up on global setdown, the deprecated sample GLator demonstrates this. The advantage/disadvantage of this depending on your case is that all instances of your plugin share this pool. Alternatively you can cache resources in sequence data which is unique per instance of your plugin and you can clean it on a sequence setdown call which AE calls at it's will.
Copy link to clipboard
Copied
i agree with james. best strategy is to allocate during rendering and freeing when the frame's render is done. if you must cache intermediates, sequence data is the place to put them.
as for listening to deletion/deactivation, i would advise agaist that. there's no deterministic way of telling. for example, an effect might be "cut", in which case you don't know yet if it will be "pasted" or discarded. the user might also undo a delete operation. that's why james' advise of deleting on "sequence setdown" is in my opinion the best practice, as AE does so only when an effect instance is truely purged.