# MessageCollection: what does dispose() do?

**URL:** <https://community.sendbird.com/t/messagecollection-what-does-dispose-do/5398>\
**Category:** JavaScript\
**Created:** [August 25, 2022, 4:54am UTC](https://community.sendbird.com/t/messagecollection-what-does-dispose-do/5398 "2022-08-25T04:54:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hewong](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/hewong/32/1817_2.png) [@hewong](https://community.sendbird.com/u/hewong)\
**Post date:** [August 25, 2022, 4:54am UTC](https://community.sendbird.com/t/messagecollection-what-does-dispose-do/5398/1 "2022-08-25T04:54:04Z")

</div>

Hi, I’m trying to understand what exactly does `dispose()` do for GroupChannelCollection and MessageCollection?

I can’t seemed to find the difference by console.logging the collection instance before and after calling `dispose()`.

Asking this because I’m trying to completely remove the `MessageCollection` instance after using it. Initially thought calling `messageCollection.dispose()` would work, but it seems like we could still call `messageCollection.loadNext()` after that. Is that an expected behaviour?

What I wanted to do is to clean it up from the SDK, as if it never existed. Wondering if that is only achievable by disconnecting from the SDK?

Would appreciate some help here, thank you.

---

<div class="post-metadata">

**Author:** ![hewong](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/hewong/32/1817_2.png) [@hewong](https://community.sendbird.com/u/hewong)\
**Post date:** [March 7, 2023, 6:21am UTC](https://community.sendbird.com/t/messagecollection-what-does-dispose-do/5398/2 "2023-03-07T06:21:26Z")

</div>

Hello, would appreciate if anyone could help me understand this

---

<div class="post-metadata">

**Author:** ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)\
**Post date:** [March 7, 2023, 10:42am UTC](https://community.sendbird.com/t/messagecollection-what-does-dispose-do/5398/3 "2023-03-07T10:42:33Z")

</div>

Hello @hewong,

My sincerest apologies for just a delayed response. I took a look through the code and it looks like `dispose()` does a couple of things. Such as:

- Closes background sync
- Closes changelog sync
- Unsubscribes group channel events.

If you’re looking to clear it out completely, it may be better off calling ` clearCachedData` or `clearCachedMessages` on the main Sendbird instance.

> **[default | Sendbird Chat SDK Reference - v4.3.1](https://sendbird.com/docs/chat/v4/javascript/ref/classes/_sendbird_chat.default.html#clearCachedData)**
>
> Documentation for Sendbird Chat SDK Reference - v4.3.1

> **[default | Sendbird Chat SDK Reference - v4.3.1](https://sendbird.com/docs/chat/v4/javascript/ref/classes/_sendbird_chat.default.html#clearCachedMessages)**
>
> Documentation for Sendbird Chat SDK Reference - v4.3.1
