From 191990810699fa8144f1c2ed59fe6c7a6d76d8dd Mon Sep 17 00:00:00 2001
From: David Catuhe <david.catuhe@live.fr>
Date: Thu, 26 May 2022 16:17:14 -0700
Subject: [PATCH] fix memory leak

---
 packages/dev/core/src/Materials/effect.ts | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/packages/dev/core/src/Materials/effect.ts b/packages/dev/core/src/Materials/effect.ts
index 6c0848e8b32..2e3828b778e 100644
--- a/packages/dev/core/src/Materials/effect.ts
+++ b/packages/dev/core/src/Materials/effect.ts
@@ -146,6 +146,8 @@ export class Effect implements IDisposable {
      */
     public _wasPreviouslyReady = false;
 
+    private _isDisposed = false;
+
     /**
      * Observable that will be called when effect is bound.
      */
@@ -569,6 +571,10 @@ export class Effect implements IDisposable {
             return;
         }
 
+        if (this._isDisposed) {
+            return;
+        }
+
         setTimeout(() => {
             this._checkIsReady(previousPipelineContext);
         }, 16);
@@ -1348,6 +1354,8 @@ export class Effect implements IDisposable {
             this._pipelineContext.dispose();
         }
         this._engine._releaseEffect(this);
+
+        this._isDisposed = true;
     }
 
     /**