Fixed memory leak when using custom effect in TS