# Memory issues after upgrading mediasoup to 3.18.0

**URL:** <https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897>\
**Category:** Deployment & Scalability\
**Created:** [October 27, 2025, 4:20am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897 "2025-10-27T04:20:13Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![j4gd33p](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/j4gd33p/32/2683_2.png) [@j4gd33p](https://mediasoup.discourse.group/u/j4gd33p)\
**Post date:** [October 27, 2025, 4:20am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/1 "2025-10-27T04:20:13Z")

</div>

We observed that the Mediasoup server’s memory usage started spiking after upgrading from version **3.12.0** to **3.18.0**.

We implemented all the required breaking changes during the upgrade, such as updating `listenIps` to `listenInfos`, replacing `announcedIp` with `announceAddress`, and manually defining UDP or TCP priorities.

The graphs below show the server’s memory performance with Mediasoup **3.12.0** and after upgrading to **3.18.0**. Following repeated crashes caused by high memory usage, we reverted back to version **3.12.0** , after which the system stabilized again.  
Are we missing something ?

`mediasoup-client` - `3.15.2`  
`mediasoup server` - `3.18.0` then reverted to `3.12.0`  
`Node` - `20.14.0`

and there was openssl error that was happening in 3.12.0 but reduces in 3.18.0, but was still happening

 ![image](https://global.discourse-cdn.com/free1/uploads/mediasoup/original/2X/8/8f914bdbc4247bd12c7117762c43cdbc3ad685ea.png)

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [October 27, 2025, 8:53am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/2 "2025-10-27T08:53:40Z")

</div>

3.12 was released on May 2023… Check which process (node|C++ worker) it using the memory. You are most probably having a leak on your application.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [October 27, 2025, 9:17am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/3 "2025-10-27T09:17:08Z")

</div>

The thing is that they are using the very same Node application.

---

<div class="post-metadata">

**Author:** ![j4gd33p](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/j4gd33p/32/2683_2.png) [@j4gd33p](https://mediasoup.discourse.group/u/j4gd33p)\
**Post date:** [October 27, 2025, 9:40am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/4 "2025-10-27T09:40:06Z")

</div>

Node version we are at is - `20.14.0`

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [October 27, 2025, 9:54am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/5 "2025-10-27T09:54:45Z")

</div>

> [@jmillan](#):
>
> Check which process (node|C++ worker) it using the memory.

I would suggest to try some intermediary version until you get the exact version where this memory usage behaviour changed. Also, don’t forget to check which process is taking the memory (node or mediasoup-worker)

---

<div class="post-metadata">

**Author:** ![j4gd33p](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/j4gd33p/32/2683_2.png) [@j4gd33p](https://mediasoup.discourse.group/u/j4gd33p)\
**Post date:** [October 27, 2025, 10:05am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/6 "2025-10-27T10:05:35Z")

</div>

We upgraded to `3.18.0` after checking the [changelog](https://classic.yarnpkg.com/en/package/mediasoup) for all intermediary versions.  
There were memory spikes in `3.12.0` but very rare. to resolve those we upgraded to `3.18.0 `because there very many fixes related to memory leak that got fixed between `3.12.0` to `3.18.0`  
We find `3.18.0` very stable based on **changelog info** and at last we have to revert back

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [October 27, 2025, 10:28am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/7 "2025-10-27T10:28:34Z")

</div>

Please try my previous suggestions.

---

<div class="post-metadata">

**Author:** ![j4gd33p](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/j4gd33p/32/2683_2.png) [@j4gd33p](https://mediasoup.discourse.group/u/j4gd33p)\
**Post date:** [October 27, 2025, 10:36am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/8 "2025-10-27T10:36:36Z")

</div>

Sure, checking the process

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [October 27, 2025, 11:05am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/9 "2025-10-27T11:05:06Z")

</div>

Probably not the culprit, but mediasoup latest versions require Node \>= 22.

---

<div class="post-metadata">

**Author:** ![HARJEETSINGHX](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/harjeetsinghx/32/2824_2.png) [@HARJEETSINGHX](https://mediasoup.discourse.group/u/HARJEETSINGHX)\
**Post date:** [October 27, 2025, 11:28am UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/10 "2025-10-27T11:28:02Z")

</div>

We have checked that the MediaSoup cores are taking memory and not releasing it even after the workers are closed. It will keep increase till the server crashed.

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [October 27, 2025, 12:03pm UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/11 "2025-10-27T12:03:20Z")

</div>

Closing a worker should terminate the spawned C++ process, and terminating a process will release it’s memory.

Can you confirm that calling `worker.close()` does not terminate the underlaying `mediasoup-worker` process?

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [October 27, 2025, 2:19pm UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/12 "2025-10-27T14:19:15Z")

</div>

The FlatBufferBuilder instances are pretty hefty, builder.clear() doesn’t actually free the memory, it just resets it for reuse so over time that may grow till the thread/worker is closed. If there’s a “leak” beyond that, I’d have to keep scouting.

This may explain why crashing could occur if there’s no memory available for retransmission or whatever scenario needs to fire off.

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [October 27, 2025, 2:39pm UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/13 "2025-10-27T14:39:03Z")

</div>

> [@BronzedBroth](#):
>
> builder.clear

`FlatBufferBuilder` is either, `thread_local` or a private member for `ChannelSocket`, meaning it is released when the thread/process terminates or the `ChannelSocket` is destructed.

The buffers are only cleared so they are reused and there’s no need to re-allocate the buffer for each message. I don’t see any problem there. The buffers will be released once the `FlatBufferBuilder` destroys. We would have a lot of trouble if that was not the case.

If you want to discard this is the problem, then revert the PR that introduced that, [here](https://github.com/versatica/mediasoup/pull/1422).

There are some unresponded questions. Please try to respond to the questions we make, so we can help.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [October 27, 2025, 2:54pm UTC](https://mediasoup.discourse.group/t/memory-issues-after-upgrading-mediasoup-to-3-18-0/6897/14 "2025-10-27T14:54:04Z")

</div>

> [@BronzedBroth](#):
>
> This may explain why crashing could occur if there’s no memory available for retransmission or whatever scenario needs to fire off.

AFAIK this has never happened and nobody has reported it. If memory exhausts then anything can fail obviously.
