Search Issue Tracker

By Design

Votes

21

Found in

2021.3.45f1

2022.3.51f1

6000.0.0f1

6000.0.25f1

6000.1.0a2

6000.2.0a1

6000.3.0a1

Issue ID

UUM-86352

Regression

Yes

Garbage Collector memory leak when allocating and deallocating memory in Web builds

-

How to reproduce:
1. Open the attached “webgl-gc-bug,zip” project
2. Open the “SampleScene”
3. Build and Run the project using the WebGL/Web platform
4. In the built project, click the “Allocate” button 5 times
5. Click the “Clear” button
6. Click the “GC” button
7. Observe the result

Expected result: “monoUsedHeapSize” shows a value of 2 (same as the starting value)
Actual result: “monoUsedHeapSize” shows a higher value, such as 32 or 62

Reproducible in: 2021.3.45f1, 2022.3.51f1, 6000.0.25f1, 6000.1.0a2
Not Reproducible in: 2023.3.0b10 (52ddac442a2c)

Reproducible on: Windows 11
Not reproducible on: No other environments tested

Last known good version: 2023.3.0b10 (52ddac442a2c)
First known bad version: 6000.0.0f1 (4ff56b3ea44c)

Note: Only reproducible in WebGL/Web build

  1. Resolution Note:

    Thank you for reporting a bug to Unity.

    After thorough analysis, we have determined that the behavior observed is not a bug but rather a limitation of the Boehm-Demers-Weiser garbage collector that our platform is currently using. This garbage collector operates as a conservative garbage collector, meaning it does not have explicit knowledge of which regions of memory store pointers. As a result, it can occasionally falsely identify certain memory allocations as being referenced, preventing them from being freed.
    While this behavior may seem unexpected, it is consistent with the design and functionality of this type of garbage collector. Unfortunately, this limitation is intrinsic to the technology and cannot be modified within the current implementation.
    We understand that this may impact certain use cases, and we encourage you to explore alternative approaches or optimizations in your application design to mitigate potential side effects.
    Thank you again for taking the time to report this issue, and please let us know if there is anything else that changes the impact or severity of this issue.

Comments (2)

  1. Sagan_CottenhamB

    Jul 10, 2025 14:40

    Was this limitation in place during all the previous versions when everything worked as expected? I'm struggling to understand what we can do now to make our web app actually function without running into consistent OOM issues.

  2. Astro75

    Apr 29, 2025 09:08

    Link to github repo that reproduces this issue: https://github.com/astro75/unity-webgl-gc-bug
    Link to forum discussion: https://discussions.unity.com/t/unity-web-gc-bug/1559486

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.