Dispose and Cache Region

Hi, just learnt something so if someone wonder :

This is just a TFX wrapped into a Class implementing the interface ITextureFX note that the Operations Dispose here is necessary.
image

Now here is a basic factory class using a switch :
image

Finally two ways to create a TFX on the fly using the Factory or just a Switch within the Cache Region :

The input pin Dispose Cached Outputs must be set to true so when a change occurs on the Index inputs and the cache region create a new TFX the Dispose operation will be called.

If you don’t do that, then ==> Memory Leak <==

TFXFactoryAndCacheRegion.vl (27.8 KB)

Worth mentioning that if a node inside the class has a Dispose operations then this will be enough to Dispose the class that contains it.

More infos here : Creating and disposing VL.Audio player leaks memory? - #11 by tonfilm

Big thanks to @tonfilm

1 Like

You don’t have to create the Dispose operation explicitly, the TextureFX process node has one and it will therefore introduce it automatically.

You only have to create it if you have no process node in the patch and you want to assign things to Dispose.

1 Like

Alright

here is the updated patch then :
TFXFactoryAndCacheRegion.vl (27.7 KB)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.