# onSessionDestroyed callback can not be unregistered, causing a memory leak

**URL:** <https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636>\
**Category:** UI ToolKit\
**Created:** [November 10, 2025, 7:25pm UTC](https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636 "2025-11-10T19:25:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcocarosi](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@marcocarosi](https://devforum.zoom.us/u/marcocarosi)\
**Post date:** [November 10, 2025, 7:25pm UTC](https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636/1 "2025-11-10T19:25:27Z")

</div>

(also posted in github `zoom/videosdk-ui-toolkit-web` issue #97.  
Please go there for links and screenshots since this forum does not allow me to add them 🤷‍♂️ )

The `onSessionDestroyed` callback can not be unregistered, there is no `offSessionDestroyed` API in the uitoolkit SDK. While similar functions exist for join and close session event: `offSessionJoined` and `offSessionClosed`.

This causes the callback to be called twice the second time the uitoolkit is used, 3 times the third, and so on.

Applies all UI toolkit SDK releases (latest checked is version 2.3.0-2).

This memory leak can be easily observed in the `zoom/videosdk-ui-toolkit-react-sample` app, see screenshot:

- removed screenshot

I have also created a test app based on nextjs to document bugs that are impacting our deployment, ref to github `ercaronte/videosdk-ui-toolkit-nextjs-sample`.  
You can observe the same behavior there as well, see screenshot:

- removed screenshot

---

<div class="post-metadata">

**Author:** ![marcocarosi](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@marcocarosi](https://devforum.zoom.us/u/marcocarosi)\
**Post date:** [November 11, 2025, 9:47am UTC](https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636/2 "2025-11-11T09:47:32Z")

</div>

In addition to the missing `offSessionDestroyed`, the `uitoolkit.destroy()` could clear all registered callbacks.  
That would simplify the user code and reduce the chances of leaks or misbehaviors.  
What do you think?

---

<div class="post-metadata">

**Author:** ![ticorrian.heard](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ticorrian.heard/32/70213_2.png) [@ticorrian.heard](https://devforum.zoom.us/u/ticorrian.heard)\
**Post date:** [November 12, 2025, 7:19pm UTC](https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636/3 "2025-11-12T19:19:03Z")

</div>

Hi @marcocarosi I reported this to the UIToolkit team and waiting for their response. In the meantime, are you able to refresh the page when you leave the session to release the callback as a temporary workaround?

---

<div class="post-metadata">

**Author:** ![marcocarosi](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@marcocarosi](https://devforum.zoom.us/u/marcocarosi)\
**Post date:** [November 13, 2025, 3:11pm UTC](https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636/4 "2025-11-13T15:11:56Z")

</div>

Hi @ticorrian.heard , thank you for your feedback.  
Yes refreshing the page does clear the status and all callbacks are released.

Knowing the issue I could come up with workarounds in our production app, so that multiple calls of the same function are not affecting the overall app status.

---

<div class="post-metadata">

**Author:** ![ticorrian.heard](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ticorrian.heard/32/70213_2.png) [@ticorrian.heard](https://devforum.zoom.us/u/ticorrian.heard)\
**Post date:** [November 17, 2025, 6:21pm UTC](https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636/5 "2025-11-17T18:21:32Z")

</div>

Thanks for confirming that @marcocarosi . I’m discussing with engineering now on a ETA for releasing a `offSessionDestroyed` callback or implementing additional teardown logic in the `.destroy()` method. I can keep you updated on the info here.

---

<div class="post-metadata">

**Author:** ![Aron](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/aron/32/50453_2.png) [@Aron](https://devforum.zoom.us/u/Aron)\
**Post date:** [February 20, 2026, 5:15pm UTC](https://devforum.zoom.us/t/onsessiondestroyed-callback-can-not-be-unregistered-causing-a-memory-leak/138636/7 "2026-02-20T17:15:46Z")

</div>

Yeah, that’s frustrating. We saw something similar on the Slushy Noobz merch [site](https://slushynoobz-merch.com/) where an event listener kept stacking and slowed the site after reloads. An offSessionDestroyed option would really help fix this. Hope they patch it soon.
