Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process memory leak while running page #59

Open
MiheevN opened this issue May 25, 2022 · 3 comments
Open

Process memory leak while running page #59

MiheevN opened this issue May 25, 2022 · 3 comments

Comments

@MiheevN
Copy link

MiheevN commented May 25, 2022

On a complex page, like YouTube, process memory is constantly growing as it runs. Sometimes at 5mb per second. If the page is simple, then it doesn't grow.

Used by Veldrid

@MiheevN
Copy link
Author

MiheevN commented Jun 23, 2022

Need independent tests to identify cause

@niclasastrom
Copy link

niclasastrom commented Mar 4, 2024

We are noticing the same thing. A "simple" web page updating a clock that shows time (incuding milliseconds) makes the process memory increase. Not fast, but slow. Eventually, the process will run out of memory.

@niclasastrom
Copy link

This code example leaks 5.3Gb over 9.5 hours, equal to 9,4Mb per minute. Tested on Windows 11 Pro (10.0.22631), VS 2022 v17.8.3

using System.Diagnostics;
using UltralightNet;
using UltralightNet.AppCore;

var initUsage = Process.GetCurrentProcess().PrivateMemorySize64;
Console.WriteLine("Memory usage after before initializing renderer: " + initUsage / (1024 * 1024));

AppCoreMethods.SetPlatformFontLoader();

var cfg = new ULConfig();
var renderer = ULPlatform.CreateRenderer(cfg);
var view = renderer.CreateView(1980, 1024);
bool loaded = false;

view.OnFinishLoading += (_, _, _) =>
{
loaded = true;
};

view.URL = "https://demo.vindral.com/clock?scale=4";

while (!loaded)
{
renderer.Update();
Thread.Sleep(10);
}

long startMem = -1;
var frameCount = 0;
var startTime = DateTime.Now;

renderer.LogMemoryUsage();

while (!Console.KeyAvailable)
{
frameCount += 1;

renderer.Update();
renderer.Render();
renderer.PurgeMemory();

//Thread.Sleep((int)Math.Round(1000/60f));

if (frameCount %10000 == 0)
{
    var proc = Process.GetCurrentProcess();
    var memUsage = proc.PrivateMemorySize64;

    if (startMem == -1)
        startMem = memUsage;

    if (DateTime.Now > startTime.AddSeconds(1))
    {
        double seconds= (DateTime.Now - startTime).TotalSeconds;
        var uptime = (DateTime.Now - startTime);
        Console.WriteLine("Uptime: "+uptime +"  Frame # " + frameCount + "  MemUsage (MB): " + memUsage/(1024*1024) + "  Diff from start (MB): " + (memUsage - startMem)/(1024*1024) + "  Diff per second avg (KB): " + (((memUsage - startMem) / seconds)/1024).ToString("F0"));
    }
    proc.Dispose();
}

}

renderer.LogMemoryUsage();
renderer.Dispose();
view.Dispose();

System.GC.Collect();

var exitUsage = Process.GetCurrentProcess().PrivateMemorySize64;
Console.WriteLine("Memory usage after disposing renderer: "+exitUsage / (1024 * 1024));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants