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

Memory leak when using CefSharp.BindObjectAsync(). #2432

Closed
HTD opened this issue Jun 26, 2018 · 5 comments
Closed

Memory leak when using CefSharp.BindObjectAsync(). #2432

HTD opened this issue Jun 26, 2018 · 5 comments
Milestone

Comments

@HTD
Copy link

HTD commented Jun 26, 2018

  • What version of the product are you using?
    65.0.0-pre02 (NuGet)

  • What architecture x86 or x64?
    Both.

  • On what operating system?
    Win10.

  • Are you using WinForms, WPF or OffScreen?
    OffScreen.

  • What steps will reproduce the problem?
    A huge memory leak occurs on each page reload when CefSharp.BindObjectAsync() is used.

To reproduce run the test project: https://github.com/HTD/CefSharpTest

When run in probably less than a minute memory usage of CefSharp.BrowserSubprocess.exe will grow exceeding 100MB, soon exceeding 1GB and more. Switch IsFullTestEnabled field to false and rerun the test. The described memory leak will not occur.

When IsFullTestEnabled field is set to false the bound class is still cached during each reload, but it is unavailable (not bound) after reloading.

It is expected, that binding the same object on each page reload should not cause a memory leak.

@HTD
Copy link
Author

HTD commented Jun 27, 2018

I just tested it with CefSharpSettings.LegacyJavascriptBindingEnabled = true; option and legacy JSB, no memory leak, work as charm, so clearly new JSB is broken. Any clues? Is it possible the problem is in CefSharp, not CEF itself?

@amaitland
Copy link
Member

To reproduce run the test project: https://github.com/HTD/CefSharpTest

Thanks for providing an example 👍

Any clues? Is it possible the problem is in CefSharp, not CEF itself?

No idea at this stage. The V8 Javascript Engine is constantly evolving, what worked in a previous version doesn't always work in a newer ones, #2390 is a recent example of that.

@HTD
Copy link
Author

HTD commented Jun 27, 2018

Looks like a duplicate, but in my case the leak is not present in legacy mode, only in the native one. BTW, it seems to be present since 63.x, I just haven't tested it well enough with that version.

@amaitland
Copy link
Member

Running the WPF example and using BindingTest.html as a more complete example, calling Reload every 10 seconds and I'm seeing pretty much what I expect, memory usage rises, then the GC kicks in and reclaims it. There does appear to be a leak when you refresh the browser every second, which has me wondering if the GC doesn't have time to run.

Relevant commit 57d60e9

@amaitland amaitland added this to the 69.0.0 milestone Aug 27, 2018
@amaitland
Copy link
Member

Testing with b0af05a and the Javascript GC appears to be working again, the memory usage goes up and after a short period of time comes back down to a manageable level. I've not seen it rise past 150mb on my machine, this will likely vary depending on hardware/operating system.

Closing as unable to reproduce with newer versions.

amaitland added a commit that referenced this issue Aug 27, 2018
…o an anon function

Use CefV8Context::Eval to create the promise using an anonymous function

Attempt to resolve #2432 (though it actually seems upgrading to a newer version resolves the underlying problem)
jviolas added a commit to intuiface/CefSharp that referenced this issue Dec 3, 2018
…o an anon function

Use CefV8Context::Eval to create the promise using an anonymous function

Attempt to resolve cefsharp#2432 (though it actually seems upgrading to a newer version resolves the underlying problem)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants