Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possible memory leak?
#8
Hi there Sonrisa
Sorry for the necropost, but I thought it made more sense than a new one since it's related to this issue.
In Obi Cloth v6.0.1 I'm also seeing a large leak with the Particle Collision constraint enabled. My test setup is as follows:
-Use the "Wind" Obi Cloth sample scene
-Remove Solver 2 and Fan
-Add an object with the following script to log memory use (quicker for this and the mem profiler)
Code:
using UnityEngine;
using UnityEngine.Profiling;

public class MemoryLogger : MonoBehaviour
{
    const float MemMultiplier = 1.0f / (1024 * 1024);

    [SerializeField]
    private float baselineDelaySecs = 10.0f;
    [SerializeField]
    private float updatePeriodSecs = 1.0f;

    private float timer;
    private float baselineTimer;
    private float baselineTimeSinceStart;
    private long baselineAllocatedMem;

    void OnEnable()
    {
        baselineTimer = baselineDelaySecs;
        timer = updatePeriodSecs;
    }

    // Update is called once per frame
    void Update()
    {
        if (baselineTimer > 0.0f)
        {
            if ((baselineTimer -= Time.deltaTime) < 0.0f)
            {
                baselineTimeSinceStart = Time.realtimeSinceStartup;
                baselineAllocatedMem = Profiler.GetTotalAllocatedMemoryLong();
                string message = $"Baseline mem in use: {baselineAllocatedMem * MemMultiplier:f1}MB.";
                Debug.Log(message);
            }

            return;
        }

        if ((timer -= Time.deltaTime) < 0.0f)
        {
            long memAllocated = Profiler.GetTotalAllocatedMemoryLong();
            int timeSinceBaseline = (int)(Time.realtimeSinceStartup - baselineTimeSinceStart);
            float memDeltaSinceBaseline = memAllocated - baselineAllocatedMem;
            string message = $"Mem in use: {memAllocated * MemMultiplier:f1}MB. " +
                             $"Time since baseline: {timeSinceBaseline/60}:{timeSinceBaseline%60}. " +
                             $"Mem delta since baseline: {memDeltaSinceBaseline * MemMultiplier:f1}MB";
            Debug.Log(message);
            timer = updatePeriodSecs;
        }
    }
}

My package versions are as follows:
-Burst 1.3.0-preview.12
-Collections 0.9.0-preview.6
-Mathematics 1.1.0

I have run the test you described in the unity forum thread, reproduced the massive leak in collections in a pre-0.2.0 version of that package (wow!) and confirmed it does not exist in 0.9.0. There does still seem to be a much smaller leak, but nowhere near that.

Now with the above setup, built to an executable to ensure no editor shenanigans, my output after a minute is as follows:
"Mem in use: 221,4MB. Time since baseline: 1:0. Mem delta since baseline: 150,3MB"

The leak continues at this pace as long as I leave the app running.

If I disable just the Particle Collision constraint on Solver 1, there is no leak.
Reply


Messages In This Thread
Possible memory leak? - by LogaNRV - 24-03-2021, 03:11 AM
RE: Possible memory leak? - by josemendez - 24-03-2021, 08:54 AM
RE: Possible memory leak? - by LogaNRV - 25-03-2021, 03:07 AM
RE: Possible memory leak? - by josemendez - 26-03-2021, 08:59 AM
RE: Possible memory leak? - by LogaNRV - 27-03-2021, 02:15 AM
RE: Possible memory leak? - by josemendez - 29-03-2021, 09:57 AM
RE: Possible memory leak? - by LogaNRV - 29-03-2021, 11:04 PM
RE: Possible memory leak? - by flintza - 13-01-2022, 01:24 PM
RE: Possible memory leak? - by josemendez - 14-01-2022, 08:48 AM
RE: Possible memory leak? - by litefeel - 07-03-2022, 01:13 PM
RE: Possible memory leak? - by josemendez - 07-03-2022, 01:23 PM
RE: Possible memory leak? - by SpiralCircus - 14-03-2022, 02:27 PM
RE: Possible memory leak? - by josemendez - 14-03-2022, 02:38 PM
RE: Possible memory leak? - by SpiralCircus - 14-03-2022, 02:57 PM
RE: Possible memory leak? - by josemendez - 17-03-2022, 09:38 AM