sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
414 stars 94 forks source link

Memory Leak in TestAppWinForms #214

Closed peder2key closed 1 year ago

peder2key commented 2 years ago

Hello

I am testing the TestAppWinforms and just by looking at the visual studio diagnostic tool it looks like the app i leaking memory:

The app starts at 26mb and after starting and stopping recording for 5-6 times it goes up all the way to 1.5gb. Any tips?

Snag_12877198

sskodje commented 1 year ago

I'm able to reproduce the same thing when using software encoding. For some reason, the MF h264 software encoder does not work properly when called from Winforms, and giving no errors. It's quite strange, because the exact same code works on tests, WPF or console apps.

peder2key commented 1 year ago

Interesting. I don't have the problem with memory leaking in the WPF app. But I got a exception when I stopped recording with the winforms app. But not sure if that a clue or not:

image

godute commented 1 year ago

Hello, I have the same problem. But I am developing with WPF.. Visual Studio : 2019 ScreenRecordLib : 5.1.4

When I call Recorder.Record, my memory jumps. And calling Recorder.Stop doesn't decrease memory (Even if I call dispose)

peder2key commented 1 year ago

I dont know if this is any help, but I downgraded the nuget package to 5.1.0 and the memory leak was not there anymore.

sskodje commented 1 year ago

That's helpful, as i can see what's changed since then. 👍

godute commented 1 year ago

wow in my case, I solved at 3.2.0. thank you image

sskodje commented 1 year ago

Fixed with 4423c27e1df1e0a92beb9d0c0f8b472dcf94cabb