Search Issue Tracker

Won't Fix

Votes

0

Found in

2021.3.31f1

2022.3.11f1

2023.1.16f1

2023.2.0b12

2023.3.0a8

Issue ID

UUM-52888

Regression

No

Memory leak when using NetworkInterface.GetAllNetworkInterfaces

-

How to reproduce:
1. Open the attached project "testiphlpmemleak.zip"
2. Enter Play Mode
3. Open Analysis>Profiler
4. Select the "Memory" tab in the Profiler window

Expected results: "Unknown" memory is not increasing
Actual results: "Unknown" memory is increasing

Reproducible with: 2021.3.30f1, 2022.3.10f1, 2023.1.14f1, 2023.2.0b10, 2023.3.0a6

Reproducible on: Windows 10 22H2
Not reproducible on: No other environment tested

  1. Resolution Note:

    We are not planning to correct this leak. We expect that this API method will not be called often during a process.

Comments (2)

  1. destenson-dft

    Feb 14, 2025 17:25

    "We expect that this API method will not be called often during a process."

    Unfortunately, this leak is actively causing us problems, since we have an application that runs for months & needs to update the network state often.

  2. destenson-dft

    Sep 05, 2024 18:30

    Did Unity investigate the cause of the leak or just conclude it isn't important for the vast majority of users?

    I have recently done a bit of a deep dive & found it's most likely to be caused by code like line 56 here: https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mcs/class/System/System.Net.NetworkInformation/Win32NetworkInterface.cs#L56
    The ptr returned by Marshal.AllocHGlobal(len) on that line is never Marshal.FreeHGlobal(ptr) freed. It seems pretty straightforward to add the call to free the memory before returning.

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.